zoukankan      html  css  js  c++  java
  • 取得AD中某个组织下所有用户的登录名

        string strLDAP = ConfigurationSettings.AppSettings["LDAP"];
         
    string strUserName = ConfigurationSettings.AppSettings["userName"];
         
    string strUserPwd = ConfigurationSettings.AppSettings["userPwd"];

         DirectoryEntry entry 
    = new DirectoryEntry(strLDAP, strUserName, strUserPwd);
         DirectorySearcher mySearcher 
    = new DirectorySearcher(entry);
         mySearcher.PageSize 
    = 99999;  // 默认为1000,此处要注意,可能会造成取用户不全。
         mySearcher.Filter = ("(objectClass=user)"); //user表示用户,group表示组

         SearchResultCollection userCollection 
    = mySearcher.FindAll();
         
    string[] users = new string[userCollection.Count];

         
    for (int i = 0; i < userCollection.Count; i++)
         {
               DirectoryEntry oneUser 
    = new DirectoryEntry(userCollection[i].Path);
               
    if (oneUser.Properties.Contains("userPrincipalName"))
               {
                   users[i
    = oneUser.Properties["userPrincipalName"].Value.ToString();
               }
               
    else
               {
                   users[i
    = "NULL";
               }
         }

         
    return users;
  • 相关阅读:
    Sobel边缘检测(2)-matlab
    Sobel边缘检测(1)
    FPGA-高斯滤波
    MySQL 常用30种SQL查询语句优化方法
    探索测试
    下拉菜单的选取
    163邮箱登录账号密码定位的问题
    python编码
    selenium python 如何控制网页内嵌div中滚动条的滚动
    Chrome正收到自动测试软件的控制 怎么去掉
  • 原文地址:https://www.cnblogs.com/kxlf/p/1487658.html
Copyright © 2011-2022 走看看