• 根据当前域来读取OU=xxx下的所有用户 muddy


           using System.DirectoryServices;

        IList<ADEntity> entityList = new List<ADEntity>();//保存实体的List集合,作为以后操作的数据源使用 //根据当前域来读取OU=xxx下的所有用户 public IList<ADEntity> ReadAD() { try { System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(); //entry.Children.Find只能读取下一集如果要下下级要在后面继续加Children.Find
    System.DirectoryServices.DirectoryEntry ou
    = entry.Children.Find("OU=xxx"); System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(ou); mySearcher.Filter = ("(objectClass=user)"); //user表示用户 foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll()) { } } catch (Exception ex) { } finally { } return entityList; }
  • 相关阅读:
    流程控制语句
    lminus
    TCL create list from file
    DFT 问答 III
    DFT 问答 II
    DFT 问答 I
    猜字符小游戏
    用户模式构造
    基元线程同步构造
    七大原则,24种设计模式
  • 原文地址:https://www.cnblogs.com/muddy/p/2471826.html
Copyright © 2020-2023  润新知