Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all ,
i want to know how to get user name and password based on windows identity. there will be no login screen if user is valid based on active directory he can access website otherwise not. how can we set this? can some one please help me where to start ?
Posted

1 solution

AD password encrypted internally so except password rest of all user info you can get by using "PrincipalContext " class that will be available in System.DirectoryServices.

// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// find user by name
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "John Doe");

// if we found user - inspect its details
if(user != null)
{
    string firstName = user.GivenName;
    string lastName = user.Surname;
    string email = user.EmailAddress;
    string phone = user.VoiceTelephoneNumber;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900