/// <summary> /// 获取用户DirectoryEntry对象的隶属组的DN。完全转义。 /// </summary> /// <param name="includePrimaryGroup">是否包括PrimaryGroup</param> /// <param name="userName">用户身份标识--用户名。为空时使用默认用户身份标识。</param> /// <param name="password">用户身份标识--密码。</param> /// <returns></returns> public List <string> GetMemberOfDN(bool includePrimaryGroup, string userName, string password) { List <string> dn = new List <string>(); if (includePrimaryGroup) { DirectoryEntry primary = ADManager.GetBySid(this.PrimaryGroupSID, userName, password); if (primary != null) { dn.Add(Utils.EscapeDNBackslashedChar(primary.Properties[BaseObject.PROPERTY_DN].Value.ToString())); primary.Close(); primary.Dispose(); } } dn.AddRange(this.memberOf); return(dn); }