I have a web application with windows authentication. When I debug the line
var domainContext = new PrincipalContext(ContextType.Domain, "abc");
where "abc" is domain name.
I can see the connected server as domain controller name. I would like to know from where it is getting the DC name.
Actually, the issue is, even though a particular DC is demoted and new DC is added, our application always pointing to the same demoted DC and throws error when we try to get groups of the user using the below lines.
var user = UserPrincipal.FindByIdentity(domainContext, "username");
var groups = user.GetGroups();
[ActiveDirectoryServerDownException: The server is not operational.
Name: "DomainController.Domain.com"
]
System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName) +510
System.DirectoryServices.ActiveDirectory.DirectoryEntryManager.ExpandWellKnownDN(WellKnownDN dn) +239
System.DirectoryServices.ActiveDirectory.DomainController.get_Domain() +71
System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOf(Principal p) +839
System.DirectoryServices.AccountManagement.Principal.GetGroups() +32
Do I need to clear IIS cache or some other cache? I have restarted the IIS too.