AD domain account logon, ad domain account
There are two modes to read and write domain service data.
1. Lightweight Data Reading
_ Domain is the server domain Name
Obtain the connection PrincipalContext pc = new PrincipalContext (ContextType. Domain, _ domain)
Verify the account password pc. ValidateCredentials (jobNumber, password)
After referencing the System. DirectoryServices. AccountManagement namespace, perform the AD Domain Verification as follows:
Using (PrincipalContext pc = new PrincipalContext (ContextType. domain, _ domain) {// The employee ID must be all using (var userPrincipal = UserPrincipal. findByIdentity (pc, IdentityType. samAccountName, loginModel. jobNumber) {if (userPrincipal = null) {return "the account is incorrect. Enter";} if (! Pc. validateCredentials (loginModel. jobNumber, loginModel. password) {return @ "Incorrect Password. Enter";} // GivenName is the user name and Surname is the employee ID (no prefix ), name is the user Name + employee ID (no prefix) PersonDetailInfo personDetailInfo = new PersonDetailInfo () {SearchName = userPrincipal. name, UserName = userPrincipal. givenName, JobNumber = userPrincipal. samAccountName, EmailAddress = userPrincipal. emailAddress}; return personDetailInfo ;}}
2. DectoryEntry
You can obtain the data of the entire server or modify the information.
Refer to similar articles:
Http://www.it165.net/pro/html/201308/6829.html