using (PrincipalContext context = new PrincipalContext(ContextType.Domain, DomainName" )) { using (UserPrincipal user = UserPrincipal.FindByIdentity(context, "LoginName" )) { bool userExists = (user != null ); if (userExists) { Console.WriteLine( "User exists" ); Console.WriteLine(user.EmailAddress); } else { Console.WriteLine( "User doesn't exist" ); } } |
No comments:
Post a Comment