1 out of 1 rated this helpful - Rate this topic

Authentication in the Managed Client Object Models

SharePoint 2010

Published: May 2010

Available in SharePoint Online

By default, the managed client object models authenticate users by using their Windows credentials (DefaultCredentials). Optionally, you can change the authentication mode on the ClientContext object, and specify the use of Forms authentication when the server supports Forms authentication. A user must then supply a user name and password through properties on the client context object. Behind the scenes, Microsoft SharePoint Foundation 2010 calls the [Authentication Web service], obtains the correct cookie, and then makes the necessary object model calls. To run managed client code against a Forms authentication server, you must change to Forms authentication. This requirement does not apply to the JavaScript object model.

The managed client object models provide a ClientAuthenticationMode enumeration whose values are Anonymous, Default, and FormsAuthentication. To specify Forms authentication, use code similar to the following.

clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;

In addition to setting the authentication mode, you must specify the user name and password information, as shown here.

FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("MyUser", "MyPassword");

clientContext.FormsAuthenticationLoginInfo = formsAuthInfo;
Note Note

In the example, if the account name and password contained in formsAuthInfo are sent in clear text, you must use HTTPS protocol instead of HTTP.

Date

Description

May 2010

Initial publication

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.