Using Windows AD in identity server to authenticate user and in that response we are not getting user information like e-mail, first name, last name.
To get the user information, we are using this code:
Thread.GetDomain().SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
UserPrincipal up;
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
{
up = UserPrincipal.FindByIdentity(pc, principal.Identity.Name);
// or return up.GivenName + " " + up.Surname;
}
But it throws an exception “LDAP Server unavailable” and this server can’t be contacted.
How to get the user information without using that unavailable LDAP server?
1