Tag: account management

如何使用PrincipalContext搜索全局编录(整个林)

myUserList AppUsers = new myUserList(); using (PrincipalContext pcxt = new PrincipalContext(ContextType.Domain, domainName)) { UserPrincipal User = new UserPrincipal(pcxt); User.EmailAddress = emailString; PrincipalSearcher srch = new PrincipalSearcher(User); foreach (var principal in srch.FindAll()) { var p = (UserPrincipal)principal; myUserRow User = AppUsers.NewUsersRow(); User.FirstName = p.GivenName; User.LastName = p.Surname; User.Email = p.EmailAddress; AppUsers.AddUsersRow(User); } } 我有类似于上面的代码,使用PrincipalContext类在Active Directory中搜索用户信息。 正如您所看到的,我在搜索过程中传入了domainName。 […]