Tuesday, November 18, 2014

AD Users not getting resolved in People Picker

Issue:- Any New User or Group created in Active Directory is not getting resolved in a specific SharePoint Site collection People Picker. It works fine for other Web Applications and if you create a new Site Collection in the same Web app, People Picker is resolving new Users and Groups there.
For the problematic Site Collection, the old Existing User accounts and Groups are resolving fine, only the New ones are not getting resolved in People Picker.




Resolution:-
Get-SPSite "http://SharePoint/sites/collection" | fl > C:\props.txt
If you open the Props.txt file, you will see the properties for this site collection. Look for "UserAccountDirectoryPath" property. By Default it should be blank, if it is not, that is causing new Users in AD not to be resolved in People Picker.

To Change the Property value to Blank, follow as below.


$Site = Get-SPSite "http://SharePoint/sites/collection"
$Val=""

Saturday, November 8, 2014

Microsoft.SharePoint.SPException

Following is code is working in console application but , it is not working in aspx page.

SPSite site = http://localhost:9292;
    SPSecurity.RunWithElevatedPrivileges(() =>
    {
        SPSiteSubscription subscription = SPSiteSubscription.Create();
       site = webApp.Sites.Add(subscription, siteUrl, title, description, lcid, webTemplate, ownerLogin, ownerName, ownerEmail, null, null, null, useHostHeaderAsSiteName); // exception
       site.AdministrationSiteType = SPAdministrationSiteType.TenantAdministration;
   });

Exception Details : 

Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> 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.
at Microsoft.SharePoint.Library.SPRequestInternalClass.SetSiteQuota(String bstrUrl, UInt16 quotaId, Int64 diskQuota, Int64 diskWarning, Int32 userQuota, Double resourceUsageMaximum, Double resourceUsageWarning, Boolean bForSSC)
at Microsoft.SharePoint.Library.SPRequest.SetSiteQuota(String bstrUrl, UInt16 quotaId, Int64 diskQuota, Int64 diskWarning, Int32 userQuota, Double resourceUsageMaximum, Double resourceUsageWarning, Boolean bForSSC)
   --- End of inner exception stack trace ---
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.SetSiteQuota(String bstrUrl, UInt16 quotaId, Int64 diskQuota, Int64 diskWarning, Int32 userQuota, Double resourceUsageMaximum, Double resourceUsageWarning, Boolean bForSSC) at Microsoft.SharePoint.Administration.SPQuota.Update() at Microsoft.SharePoint.SPSite.set_Quota(SPQuota value) at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPContentDatabase database, SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, String quotaTemplate, String sscRootWebUrl, Boolean useHostHeaderAsSiteName)   at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)    at WSS4WS.ProvisioningService.<>c__DisplayClass5.<CreateSite>b__0() in C:\Projects\Web Services\WSS4WS\WSS4WS\ProvisioningService.asmx.cs:line 77    at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()    at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)    at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)    at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)    at WSS4WS.ProvisioningService.CreateSite(String webApplicationName, String siteUrl, String title, String description, UInt32 lcid, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, Boolean useHostHeaderAsSiteName)
Though the above code snippet works perfectly fine in console application but aspx is webrequest and SharePoint handles web request differently. All the webrequest validated with the FromDigest control. To get rid-off from this error message, we can change the web application validation settings in Central Administration > Web Application General Settings Page.
image
Enjoy this will solve your problem.