Tuesday, February 28, 2012

Limiting Sharepoint People picker to show users and groups from a Specific Active Directory

0 comments
In corporate environment if you have more than one Active directory, Sharepoint by Default tries to get the user and groups from all of them and shows in the People picker, it is bit annoying when this are just the Test AD’s in the network.

Sharepoint Central admin does not have any UI to configure this. However there is a work around using the STSADM (No Powershell command for web application level configurationL :(

To make it more elaborative, consider there are 3 Domain Controllers in the network, tz.com, subtz.com and test-tz.com.

Following is the Stsadm command to read the user from two of our Domain controllers except the test-tz.local.

STSADM.exe -o setproperty -pn peoplepicker-searchadforests -pv "tz.local,tz\User1,Password1;subtz.local,subtz\User2,Password2" -url http://[webapplicationurl]
Source: http://technet.microsoft.com/en-us/library/gg602066.aspx#section4

In a different scenario, we have to set this different for different site collection, following is powershell command. (domain is tz.local)

Set-SPSite -Identity http://intranet.tz.com -UserAccountDirectoryPath " dc=tz,dc=local"


To make it more specific to a particular group in the AD, following command be used to point the specific group. (domain is tz.local and group is Sales(OU=sales))

Set-SPSite -Identity http://intranet.tz.com -UserAccountDirectoryPath " Ou=sales,dc=tz,dc=local"
Source: http://technet.microsoft.com/en-us/library/ff607958.aspx

Friday, February 24, 2012

Different ways to get site collection Url (root site) and current Site url in Master page and Layouts without using code snippets in Sharepoint 2010

0 comments
In many cases Sitecollection are created at different levels using the managed paths rather than only at the root. considering these scenario while custom branding the site templates have to make sure the path are not absolute and are refering to the current site collection.

Following some of the different way to refer the resource using relative path rather than a fixed absolute paths.
  1. $SPUrl:~sitecollection :
    This is a default variable provided by Sharepoint framework. The disadvantage of this variable is it works only for server controls i.e. Controls or links with runat=server, and also in some of the cases it fails if you use it directly.
    < link rel="stylesheet" type="text/css" runat="server" href="<% $SPUrl:~sitecollection/Style%20Library/custom_style.css %>"/>
  2. SharePoint:EncodedLiteral along with SPUrl:~SiteCollection:
    This is a sharepoint Control to show Plain text out of Server variable like a label control, but can be used outside of the form tag i.e. can be used in the Head section of the master page.
    < script type="text/javascript" src='< SharePoint:EncodedLiteral runat="server" text="<%$SPUrl:~SiteCollection/style%20library/jquery.min.js%>" EncodeMethod="HtmlEncode"/>'>
  3. _spPageContextInfo.siteServerRelativeUrl:
    This is a sharepoint Javascript API variable which returns the Sitecollection relative path at any level of the subsites.
    _SitecollectionUrl = _spPageContextInfo.siteServerRelativeUrl =="/"? "" : _spPageContextInfo.siteServerRelativeUrl;
  4. L_Menu_BaseUrl:
    This is another JavaScript API variable which returns current subsite or Sites Url.
Powered by Blogger.