コード例 #1
0
 private void ReadUsers(string machine, Dictionary<string, IdentitySourceItem> userList)
 {
     try
     {
         using (DirectoryEntry root = new DirectoryEntry("WinNT://" + machine))
         {
             root.Children.SchemaFilter.Add("User");
             foreach (DirectoryEntry d in root.Children)
             {
                 var login = machine + "\\" + d.Name;
                 userList[login] = new IdentitySourceItem() { UserName = login, DisplayName = (d.Properties["FullName"].Value ?? login).ToString() };
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error("Error reading users from " + machine, ex);
     }
 }