/// <summary> /// 获取组织单位子组织单位。 /// </summary> /// <param name="userName">用户身份标识--用户名。为空时使用默认用户身份标识。</param> /// <param name="password">用户身份标识--密码。</param> /// <returns></returns> public List <OU> GetChildren(string userName, string password) { this.children = new List <OU>(); OU ou = null; foreach (DirectoryEntry c in ADManager.Search(null, "organizationalUnit", null, this.Path, SearchScope.OneLevel, userName, password)) { ou = new OU(c); ou.parent = this; this.children.Add(ou); if (c != null) { c.Close(); c.Dispose(); } } return(this.children); }
private void GetSubTree(string parentPath, string userName, string password) { this.children = new List <OU>(); OU ou = null; foreach (DirectoryEntry c in ADManager.Search(null, "organizationalUnit", null, parentPath, SearchScope.OneLevel, userName, password)) { ou = new OU(c); ou.parent = this; this.children.Add(ou); ou.GetSubTree(c.Path, userName, password); if (c != null) { c.Close(); c.Dispose(); } } }