RavenDB: Integrated Windows Authentication
A couple of days ago I was at a customer and one of the raised issues, when dealing with RavenDB Windows authentication, was how to use a real “Integrated Windows Authentication” in order to have the credentials of the user currently running the client process flow to the server through the HTTP protocol.
After a bit of digging in the .net documentation the solution is trivial:
Uri uri = new Uri( "http://localhost:8080/" ); ICredentials credentials = CredentialCache.DefaultCredentials; NetworkCredential credential = credentials.GetCredential( uri, "Basic" ); var store = new DocumentStore() { Url = "http://localhost:8080/", DefaultDatabase = "database-name", Credentials = credential }.Initialize();
The above snipped creates a new DocumentStore whose credentials are ready to transport the current user credentials.
.m