In this post, we are going to discuss on one very important aspect of client object model. But before that if you have not gone through Part 1 to Part 11, I would recommend reading them first and then continue reading from here.
You must have thought that in none of the series we talked about authentication. How does a client object model connects with the respective objects on the server like lists, sites, libraries, workflows etc.?
There are three methods.
1) Default authentication
2) Forms authentication
3) Anonymous authentication
And we have managed client object model, Silverlight client object model and ECMA script object model.
Managed COM – Windows authentication is default authentication.
So we do not need to explicitly specify anything. When we do not specify anything, it connects with our windows credentials and then checks our access on objects that we access through object model.
So we need to be very careful while writing a code that when the code runs, user should have a sufficient privilege on objects.
We can use anonymous or forms authentication with managed COM.
Silverlight COM – Same as Managed COM.
ECMA COM - Do not need any authentication. It runs inside the browser page and hence by default it has passed the parent authentication method.
Setting the Forms bases authentication on COM
If we use Forms authentication, then we need to set one more property which is AuthenticationMode on clientcontext object.
Plus we also need to make an instance of FormsAuthenticationLoginInfo class and assign the username and password before accessing or performing any operation on any SharePoint object and then set that authentication object to client context object.
FormsAuthenticationLoginInfo("UserName", "Password");
clientContext.FormsAuthenticationLoginInfo = objformsAuth;
Setting the Anonymous authentication on COM
ClientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous;
Do remember that when using this method, object which you are trying to access in code should have anonymous permission assigned.
2 comments:
for Silverlight client OM, and you want to allow anonymous access to sharepoint data, you need to run the following PoweShell commands
$webapp = Get-SPWebApplication “http://URL”
$webapp.ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], “GetItems”)
$webapp.Update()
hope this help :)
Mahmoud
Exceed IT Services -UAE
for Silverlight client OM, and you want to allow anonymous access to sharepoint data, you need to run the following PoweShell commands
$webapp = Get-SPWebApplication “http://URL”
$webapp.ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], “GetItems”)
$webapp.Update()
hope this help :)
Mahmoud
Exceed IT Services -UAE
Post a Comment