Skip to content

Instantly share code, notes, and snippets.

@olegwtf
Created May 26, 2012 07:43
Show Gist options
  • Save olegwtf/2792796 to your computer and use it in GitHub Desktop.
Save olegwtf/2792796 to your computer and use it in GitHub Desktop.
Microsoft Sharepoint Authentication
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ClientContext clientContext = new ClientContext("http://sitename");
CredentialCache cc = new CredentialCache();
cc.Add(new Uri("http://sitename"), "NTLM", new NetworkCredential("User", "Password"));
clientContext.Credentials = cc;
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
Web site = clientContext.Web;
clientContext.Load(site);
clientContext.ExecuteQuery();
Console.WriteLine("Title: {0}", site.Title);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment