Friday, November 28, 2008
CustomGroup and CustomAction in central admin application page using featurepage
Sunday, November 23, 2008
How to Deploy SharePoint WebParts
Method 1 - manual
- Copy assembly DLL to either
- /bin directory for a given IIS virtual server (e.g., c:\inetpub\wwwroot\bin)
- Global Assembly Cache (e.g., c:\windows\assembly) - Copy DWP file to C:\Inetpub\wwwroot\wpcatalog
- Copy resources to
- For GAC-registered parts, C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources
- For Web Parts in the /bin directory, C:\Inetpub\wwwroot\wpresources - Adjust web.config
- Register as SafeControl
- Select Code Access Security settings
Method 2: CAB File
- CAB file should contain
-Assembly DLL
-DWP file(s)
-Manifest.XML
-Resource files (if needed) - CAB won't contain
- Code Access Security settings - Server-side object model has methods for deploying such a CAB file
- Deploy with STSADM.EXE
Located in C:\Program Files\Common Files\Microsoft Shared\web server extensions0\BIN
Add it to your path
Stsadm -o addwppack -filename filename [-globalinstall] [-force]
New Version of the Caml Query Builder Tool
- Query fields by ID
- GetListItemChanges (method of the Lists.asmx web service)
- GetListItemChangesSinceToken (method of the Lists.asmx web service)
- extra options of the QueryOptions part
- support for data type ModStat
Adding Breadcrumb Navigation to Application Pages in SharePoint Central Administration
http://weblogs.asp.net/jan/archive/2008/10/10/adding-breadcrumb-navigation-to-application-pages-in-sharepoint-central-administration.aspx
Current Page URL in the UrlAction of a SharePoint Feature
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="{6FCB0F81-2105-4d9f-96BF-C48A19B8E439}"
Title="My Link"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="SettingsMenu">
<UrlAction Url="_layouts/mypage.aspx"/>
</CustomAction>
</Elements>
When activated, the feature will add a menu item to the Settings menu of any SharePoint list or document library. The menu item will have the title My Link, when clicked the user will navigate to the page mypage.aspx in the _layouts folder
<UrlAction Url="_layouts/mypage.aspx?listid={ListId}"/>
The {ListId} URL token will be automatically replaced with the ID of the list, in which the menu item is shown. In the mypage.aspx, you can retrieve the value of the listid parameter by making use of the QueryString. Once you've got the ID, the object model can be used to get a reference to the SPList instance of that list. According to the documentation on MSDN, the following URL tokens can be used:
- ~site - Web site (SPWeb) relative link.
- ~sitecollection - site collection (SPSite) relative link.
- In addition, you can use the following tokens within a URL:
- {ItemId} - Integer ID that represents the item within a list.
- {ItemUrl} - URL of the item being acted upon. Only work for documents in libraries. [Not functional in Beta 2]
- {ListId} - GUID that represents the list.
- {SiteUrl} - URL of the Web site (SPWeb).
- {RecurrenceId} - Recurrence index. This token is not supported for use in the context menus of list items.
Thursday, November 20, 2008
Enabling anonymous access in SharePoint 2007
First, you need to enable anonymous on the IIS web site (called a Web Application in SharePoint land). This can be done by:
- Launching Internet Information Services Manager from the Start -> Administration Tools menu
- Select the web site, right click and select Properties
- Click on the Directory Security tab
- Click on Edit in the Authentication and access control section
Instead we’ll do it SharePoint style using the Central Administration section:
- First get to your portal. Then under “My Links” look for “Central Administration” and select it.
- In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
- Select “Authentication Providers” in the “Application Security” section
- Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
- Under “Anonymous Access” click the check box to enable it and click “Save”
NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.
You can confirm that anonymous access is enabled by going back into the IIS console and checking the Directory Security properties.
Now the second part is to enable anonymous access in the site.
- Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site Actions – Site Settings – Modify All Site Settings. In WSS it’s under Site Actions – Site Settings.
- Under the “Users and Permissions” section click on “Advanced permissions”
- On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
- Select the option you want anonymous users to have (full access or documents and lists only)
Now users without logging in will get whatever option you allowed them.
A couple of notes about anonymous access:
- You will need to set up the 2nd part for all sites unless you have permission inheritance turned on
- If you don’t see the “Anonymous Access” menu option in the “Settings” menu, it might not be turned on in Central Admin/IIS. You can manually navigate to “_layouts/setanon.aspx” if you want, but the options will be grayed out if it hasn’t been enabled in IIS
- You must do both setups to enable anonymous access for users, one in IIS and the other in each site
MOSS Architecture: Model, SSP, Portal
- Search
- Index
- Audience compilation
- User profiles database
- My Sites
- Business Data Catalogue
- Excel Services
Tables within MOSS 2007
- AllDocs: holds information about all the documents (and all list items) for each document library and list
- AllLists: holds information about lists for each site
- AlllistData: holds information about all the list items for each list
- AllUserData: holds all the metadata which user provides in a document library
- GroupMembership: holds information about all the SharePoint group members
- Groups: holds information about all the SharePoint groups within each site collection
- ImmedSubscriptions: holds information about all the immediate subscriptions (alerts) for each user
- RoleAssignment: holds information about all the users or SharePoint groups that are assigned to roles
- Roles: holds information about all the SharePoint roles or permission levels for each site
- SchedSubscriptions: holds information about all the scheduled subscriptions (alerts) for each user
- Sites: holds information about all the site collections relevant to this content database
- UserInfo: holds information about all the users within each site collection
- Webs: holds information about all the specific sites (webs) in each site collection
Understanding RunWithElevatedPrivileges
Without RunWithElevatedPrivileges delegate the Sharepoint identity will be the same as of the current user identity and you are able to do whatever your own permissions allow you to do.
With RunWithElevatedPrivilages delegate the Sharepoint set the identity to Sharepoint\System. The Sharepoint\System identity doesn't have anything to do with a windows identity so you shouldn't be tempted to look for this windows account. The Sharepoint\Sytem is a built-in identity of Sharepoint and it has full permissions in Sharepoint. Also RunWithElevatedPrivilages elevates the windows privilages which means that if you are running the elevated code from a web application the applicaion is basically using the identity of the account running the webApp pool.
Incase of winforms/console application, code runs with your credentials (or if using 'runas', it would use whatever credentials you told it to use). There is no impersonation going on here like with the web application, so a call a to RunWithElevatedPrivileges will effectively do nothing because there is no impersonation to temporarily halt. You can see this is the case if you were to execute this code snippet in a console application:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb(webUrl))
{
System.Console.WriteLine(web.CurrentUser.LoginName);
System.Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
System.Console.ReadKey();
}
}
});
Note here that web.CurrentUser.LoginName is coming from the WSS identity. If you 'runas' the web application's app pool identity, it would get correlated to SharePoint\System and thats what you would see on the first line of output.
Wednesday, November 19, 2008
Hide Quick Launch using CSS
<style>
.ms-navframe
{
display:none;
}
</style>
Monday, November 17, 2008
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x8102006d): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +0
Microsoft.SharePoint.Library.SPRequest.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +119
[SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
OfficialMail.WebParts.TestWebPart.btn_Click(Object sender, EventArgs e) +94
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
Solutions :
Central Administration > Application Management > Web Application General Settings ->Select web application
In Web Page Security Validation , change security validation is off.
Thursday, November 6, 2008
some useful links....
http://sharepoint-exchange.blogspot.com/2008_02_01_archive.html
MOSS 2007 User and Profiles import from Active Directory
Its very normal to have a scenario in which the user profile information in stored in directory service like Active Directory. Since personalization in sharepoint largely depends upon user profiles it becomes imperative to not only import the user information in AD into sharepoint as user profiles but also to run incremental imports to sync up user profiles with new information added into the Active directory.
As you know sharepoint integrates with Active directory and a user profile record gets created in sharepoint when an AD authenticated user first accesses a site. Assumption here is that the user already has adequate permissions on the site. As noted above incremental imports facilitate synchronizing user information stored in AD with the profile created in sharepoint.
The following steps need to be followed to configure import of user profiles from Active Directory -
Scenario-1 - All users are in the current domain.
1. Go to User Profile and Properties under Shared Services Administration.
2. Click on configure profile import link. Select current domain as the profile datasource.
3. Make sure default access account is specified and is valid.
4. Run full import or incremental report.
Scenario-2 - Users are scattered into multiple domains or other data sources.
1. Go to User Profile and Properties under shared services administration.
2. Click on Import New Connection. Add a new connection for each of the data sources where you users are located. Delete any unwanted connections that might already be there.
3. Configure the import as mentioned above and make sure that Custom source is selected.
4. Run the full import or incremental import.