Tuesday, December 18, 2007

"No access" site in MOSS2007

If you access a readlocked site.


1. This is by design: if you access an existing page, like /default.aspx or /_layouts/settings.aspx, you will get error message:

Access to this Web site has been blocked.
Please contact the administrator to resolve this problem.

In this condition, MOSS will check the permission on page first then throw the above error if the site is locked.

But if you access a folder, like / or /subsite or /doclib, you will get

403 FORBIDDEN

Or

404 NOT FOUND

In this condition, MOSS will check redirection function first, then throw the above error if the site is locked.

2.WSS/MOSS does not support custom error pages, the only customization can be made is for 404 (File not found error) on web application. You can check this:

SPWebApplication.FileNotFoundPage Property

http://msdn2.microsoft.com/en-gb/library/microsoft.sharepoint.administration.spwebapplication.filenotfoundpage.aspx

Windows SharePoint Services does not support the custom error pages that are typically used in IIS applications. There can only be one file per SharePoint Web application, which must be in HTML and cannot contain dynamic ASP.NET controls.

do whatever you want with Farm level administrators permissions.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
// do whatever you want with Farm level administrators permissions.
}

Thursday, November 22, 2007

event handler

if you want to add a event handler for a site or web, you can't use feature to install the handler, you must use API to install it. for example, you want to overwrite the webdeleting event.

Tuesday, November 06, 2007

How to get SharePoint Central Administration webapplication URL?

Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local.Sites.VirtualServer.Url.ToString();

Monday, November 05, 2007

How to lock/unlock a site through 'post' method

We can easily lock/unlock a site through API from a console or windows application. By using the properties of SPSite, readlocked or writelocked. But have you tried to do it within a web application. There is a little tricky here.

You will receive error message "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again" .

ok, then you can do some poke around on google, someone will tell you that should include below code in Page_Load event:

Context.Items[SPGlobalAdmin.RequestFromAdminPort] = true;
Page.RegisterHiddenField("__REQUESTDIGEST", ga.AdminFormDigest);

you also need to define 'ga' in your page cs file:
Microsoft.SharePoint.Administration.SPGlobalAdmin ga = new Microsoft.SharePoint.Administration.SPGlobalAdmin();

But , it still refuse to work!! That makes me crazy!

Finally, if you put your page under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\ADMIN, a virtual directory under Sharepoint Central Administrator site. It works! The page is code-inline.

by the way, SPGlobalAdmin is obsolete now but I can't find the proper replacement regarding to its AdminformDigest property.

site template大小的限制

site template可以包含站点的内容。但是却有10mb大小的限制。用下面这个命令改成20mb。stsadm -o setproperty -pn max-template-document-size -pv 20000000这个东西其实我也没有试过,因为一开始想用site template, 后来发现用不着,但这个东西还是花了点时间在网上查到了。

有没有用过SPQuery?

This summary is not available. Please click here to view the post.