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 framework, called Geneva, pr…

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

privatevoid btnLoad_Click(object sender, EventArgs e)         { ExcelService proxy = newExcelService();             proxy.Credentials = new System.Net.NetworkCredential ("administrator", "abc123#");             XLWebService.Status[] wsStatus; string sheetName = "Sheet2"; string namedRange =…

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 -> MMCFile -> Add/Remove SnapinAdd the Certificates Snap InSelect Computer Account, then hit nextSelect Local Computer (the default), then click FinishOn the left panel from Console Root, navigate to Certificates (Local Computer) -> Personal -> CertificatesYou're certificate will most likely be here.Right click on your certificate -> All Tasks -> Manage Private KeysSet you're private key settings here.

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.
publicoverridevoid 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;             }         }
publicoverridevoid FeatureDeactivating(SPFeatureReceiverProperties properties)         { try             { SPWebService contentService = SPWebService.ContentService;                 contentService.WebConfigModifications.Remove(GetConfigModification()); // Serialize the web application s…

Why we need a AllowUnsafeUpdates.

AllowUnsafeUpdates is a property of
SPSiteSPWeb 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.aspxConfirmation.aspxError.aspxLogin.aspxReqAcc.aspxSignOut.aspxWebDeleted.aspx

For replace the default list of pages as mentioned in above. We have a classSPWebApplication Undernamespace Microsoft.SharePoint.Administration. SPWebApplication class have a SPCustomPage enum which has a following values.
publicenumSPCustomPage         { // 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.             Confirmation = 2, // // Summary: //     Specifies that the Error.aspx page will be replaced with a custom page.             Error = 3, // // Summary: //     Specifies that the Login.aspx page will be replaced with a custom …

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. How to check th…

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 { classProgram     { staticvoid 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 = newSPSite(paramListUrl))             { using (SPWeb web = site.OpenWeb())                 { string serverRelativePath = GetRelativeUrl(paramListUrl); SPList list = web.GetList(serverRelativePath);
XmlDocument doc = newXmlDocument();                     doc.Load(paramViewXml); SPView loadedView = newSPView(list, doc); SPView newView = list.Views.Add(loadedView.Title, loadedView.ViewFields.ToStri…