Reputation: 5845
I add the following to the web.config of an application that I want to require login for:
<authentication mode="Forms">
<forms loginUrl="/forms/Login" name=".ASPXAUTH" timeout="60" slidingExpiration="true">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
/forms/Login is a centralized application for authenticating apps on the same server. It has a simple Authentication class with the following method:
public static bool AuthenticateUser(String username, String password)
{
bool validated = false;
PrincipalContext pc = new PrincipalContext(ContextType.Domain, "mynet.myad.org", "dc=mynet,dc=myad,dc=org");
validated = pc.ValidateCredentials(username, password, ContextOptions.Negotiate);
return validated;
}
This works great most of the time but sometimes it seems to "lock up" and it will throw the following exception: "The server could not be contacted." It will continue throwing that exception until I restart the web server, or uninstall/re-install the login application. (I have tried restarting IIS, but this has no effect on it).
I am fairly certain it is not the AD server as the same login code continues to work on other web servers at the same time. I obviously don't want to have to continuously restart the web server or re-install the login application.
I really have no idea where to begin troubleshooting this. Any help on this would be greatly appreciated!
Upvotes: 1
Views: 2195
Reputation: 4503
I'm assuming you have multiple domain controllers in the domain? If so, it sounds like one of them is probably your culprit. My suggestion is that next time this happens you collect a network trace from the affected server and reproduce the problem. I wouldn't be surprised if there's a DNS or connectivity issue.
Upvotes: 1