I'm creating an MVC app that requires me to nab the group users from a Sharepoint site. I'm getting a 401 error when I publish and run it via IIS (localhost). When I run it through the debugger though, everything works as intended.
I'm assuming it's a permissions error based on the context. Is there a way to run the app normally using my current NTLM credentials programmatically (instead of what seems like the IIS account/user)?
Code (I'm on mobile right now, so I'm sorry if anything looks wonky...)
// Constructor
clientContext = new ClientContext("http://sharepointsite");
clientContext.Credentials = CredentialCache.DefaultNetworkCredentials;
//clientContext.Credentials = new NetworkCredentials("username", "password", "domain"); <- this works just fine if I hard code my current credentials
// Calling method
UserCollection users = GetUsersCollection();
clientContext.Load(users);
try {
clientContext.ExecuteQuery(); // 401 error here
return true;
}
catch {
return false;
}