My organization recently started the move over to a new domain/Active Directory. All of our servers are still on the old domain, while all the users are on the new domain. The old domain is now no longer receiving updates and is out of synch with the new domain. We currently can’t manage the move of the server to the new domain.
Some of the web applications on the server queried the old domain, using the names/ID’s of the users coming from the new domain. This worked while the old domain was still being synched with the new domain but is no longer working as new users no longer have records on the old domain.
This is the code that was used to find the users
public UserPrincipal FindUserDetails(string userID)
{
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, userID);
if (user == null)
{
return null;
}
return user;
}
Is there any way to configure IIS or alter this code to set the default domain? Preferably without encoding credentials in the source or referencing secrets.
I’ve tried constructing the principal context with a specific domain controller and username and password in the constructer. That worked in querying the new domain but I am looking to avoid modifying the source.
BOXFULLOFCATS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.