Posts

Showing posts from 2011

Custom Claim base Authentication with Example & Source Code

Image
Claim-based Identity This new type of authentication and authorization in way in SharePoint 2010. A trusted authority (Issuer) issues a signed security token containing a set claims (credentials) which is given to the application for validation. The application will authenticate the user if the security token is valid and signed by a trusted issuer. Applications using this type of authentication do not have to verify all the credentials. Example Claim Based Authentication Someone who determines your company's security policy can make those rules and buy or build the issuer. Your application simply receives the equivalent of a boarding pass. No matter what authentication protocol was used, Kerberos, SSL, forms authentication, or something more exotic, the application gets a signed set of claims that has information it needs about the user. This information is in a simple format that the application can use right away. Geneva framework Microsoft has created a framewor

SharePoint2010 Excel Services to read data from excel sheet

To read the data from the excel services. I have implemented the code that will get the information from the excel file stored in SharePoint Library. Read the data from excel service. This is simple Window application. To read the Excel file from SharePoint Site you need to have a full persimmon to access the web services.   Excel Web services You can view the Excel Web Services Web Services Description Language (WSDL) page by navigating to the following URL on the server: http://<server>/<customsite>/_vti_bin/excelservice.asmx?WSDL If you do not have a custom site, you can view the WSDL by using the following URL: http://<server>/_vti_bin/excelservice.asmx?WSDL   private void btnLoad_Click( object sender, EventArgs e)         {             ExcelService proxy = new ExcelService ();             proxy.Credentials = new System.Net. NetworkCredential ( "administrator" , "abc123#" );             XLWebService. S

STS CryptographicException Error : Key set does not exist

Image
Common mistakes Both SharePoint Site and SSO Site NOT running on the same application pool. Application pool identity user doesn’t have permission to access the certification.  Solution to this problem Set the same identity pool to  : 2. Be sure to grant rights to the certificate for the App Pool running the web service Start -> Run -> MMC File -> Add/Remove Snapin Add the Certificates Snap In Select Computer Account, then hit next Select Local Computer (the default), then click Finish On the left panel from Console Root, navigate to Certificates (Local Computer) -> Personal -> Certificates You're certificate will most likely be here. Right click on your certificate -> All Tasks -> Manage Private Keys Set you're private key settings here. Add app pool account Reset iis

Add Safe control entry in web.coinfig using SPWebConfigModification Class

SPWebConfigModification Class : Holds modifications that are made to the web.config. Following example helps you to add the safe control entry on feature activation. public override void FeatureActivated( SPFeatureReceiverProperties properties)         {             try             {                 SPWebService contentService = SPWebService .ContentService;                 contentService.WebConfigModifications.Add(GetConfigModification());                 // Serialize the web application state and propagate changes across the farm.                 contentService.Update();                 // Save web.config changes.                 contentService.ApplyWebConfigModifications();             }             catch ( Exception e)             {                 Console .WriteLine(e.ToString());                 throw ;             }         }         public override void FeatureDeactivating( SPFeatureReceiverProperties properties)        

Why we need a AllowUnsafeUpdates.

AllowUnsafeUpdates is a property of SPSite SPWeb If user do't have any permission to update the data. So we run the code with special permission for that we use RunWithElevatedPrivileges block, by using this code user update the item on the behalf of system account, for that we need to  Set AllowUnsafeUpdates   to true to disable security validation on Update(). This is request if persisting anything within RunWithElevatedPrivileges. Any exception, handled or otherwise, sets AllowUnsafeUpdates to False.

SharePoint2010 Replace AccessDenied.aspx, Confirmation.aspx and other page with our own custom page

In sharePoint2010, we can replace the list of the following page with our own custom page. AccessDenied.aspx Confirmation.aspx Error.aspx Login.aspx ReqAcc.aspx SignOut.aspx WebDeleted.aspx For replace the default list of pages as mentioned in above. We have a class SPWebApplication Under namespace Microsoft.SharePoint.Administration. SPWebApplication class have a SPCustomPage enum which has a following values. public enum SPCustomPage         {             // Summary:             //     Specifies that no page will be replaced with a custom page.             None = 0,             //             // Summary:             //     Specifies that the AccessDenied.aspx page will be replaced with a custom             //     page.             AccessDenied = 1,             //             // Summary:             //     Specifies that the Confirmation.aspx page will be replaced with a custom              //     page.             Confirmatio

SharePoint2010 : The root of the certificate chain is not a trusted root authority

Image
Problem : The root of the certificate chain is not a trusted root authority. Event Log Error An operation failed because the following certificate has validation errors:\n\nSubject Name: CN=<Certificate URL>, OU=Domain Control Validated, O=<Certificate URL>\nIssuer Name: SERIALNUMBER=07969287, CN=Go Daddy Secure Certification Authority, OU=http://certificates.godaddy.com/repository, O="GoDaddy.com, Inc.", L=Scottsdale, S=Arizona, C=US\nThumbprint: xxxxxxxxxxxxxxxxxxxxxx\n\nErrors:\n\n The root of the certificate chain is not a trusted root authority. Main problem is your SSO Application unable to make a trust with SharePoint 2010 Site. Common mistake: Most of developer while implementing the SSL on SharePoint Site they only include the main Certificate to SharePoint Security "Manage Trust"  i.e. (<Site URL> ). SharePoint Site unable to make the trust between the SSO Site. Solution : You need to first see the hierarchy of the certificate.

SharePoint 2010 Update Default List View By Code

SharePoint 2010 Create List view using Code. Open visual studio Create a console Application give it name and Add “Microsoft.SharePoint” Ref. to your project. using  System; using  System.Collections.Generic; using  System.Linq; using  System.Text; using  System.Xml; using  Microsoft.SharePoint; namespace  SharepointForDeveloper_AddView {      class   Program     {          static   void  Main( string [] args)         {              if  (args.Length < 2)             {                  Console .WriteLine( "Missing Parameters 1. <ListUrl> 2. <XmlFile Path>" );                  return ;             }              string  paramListUrl = args[0];              string  paramViewXml = args[1];              using  ( SPSite  site =  new   SPSite (paramListUrl))             {                  using  ( SPWeb  web = site.OpenWeb())                 {                      string  serverRelativePath = GetRelativeUrl(param