private static void getUserList(string searchFilter, ref List <User> lstUser) { DirectorySearcher ds = new DirectorySearcher(new DirectoryEntry(null)) { Filter = searchFilter }; using (SearchResultCollection collection = ds.FindAll()) { foreach (SearchResult sr in collection) { lock (dictDistinguishedUser) { string distinguishedName = null; if (sr.Properties.Contains("distinguishedName")) { distinguishedName = sr.Properties["distinguishedName"][0].ToString(); if (dictDistinguishedUser.ContainsKey(distinguishedName)) { continue; } } WindowsUser user = new WindowsUser(sr.GetDirectoryEntry()); if (user.IsValid) { if (string.IsNullOrEmpty(distinguishedName) == false) { dictDistinguishedUser.Add(distinguishedName, user); } lstUser.Add(user); } } } } }
private void initGroupMember() { if (_isGroup) { _lstMembers.Clear(); if (adUser.Properties.Contains("member")) { object[] properties = (object[])adUser.Properties["member"].Value; lock (dictDistinguishedUser) { foreach (object obj in properties) { string member_distinguishedName = obj.ToString(); if (dictDistinguishedUser.ContainsKey(member_distinguishedName)) { _lstMembers.Add(dictDistinguishedUser[member_distinguishedName]); continue; } DirectoryEntry adMember = new DirectoryEntry("LDAP://" + member_distinguishedName); WindowsUser member = new WindowsUser(adMember); if (member.IsValid) { _lstMembers.Add(member); dictDistinguishedUser.Add(member_distinguishedName, member); } } } } } _is_initilized_group_member = true; }
public static User GetUser(string userID) { switch (System.Environment.OSVersion.Platform) { case System.PlatformID.Win32NT: return(WindowsUser.GetWindowsUser(userID)); default: throw new System.InvalidOperationException("Not supported " + System.Environment.OSVersion.Platform.ToString()); } }