Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>looking though reflector at System.DirectoryServices.AccountManagement the internal class "UnsafeNativeMethods" is implemented in native code, so UserSuppliedServerName one level up is all I can go on without looking at the CLR VM, (frankly im not sure even how to do that) Seems that a node is failing to return its primary group, so perhaps consider other implementations, after a bit of googling ive come across these that may help</p> <ul> <li><p><a href="http://www.funkycoding.com/?p=345" rel="noreferrer">Active Directory and nested groups</a> <em>this one may be promising</em> heres the code sample..</p> <pre><code> public IList&lt;string&gt; FindUserGroupsLdap(string username) { // setup credentials and connection var credentials = new NetworkCredential("username", "password", "domain"); var ldapidentifier = new LdapDirectoryIdentifier("server", 389, true, false); var ldapConn = new LdapConnection(ldapidentifier, credentials); // retrieving the rootDomainNamingContext, this will make sure we query the absolute root var getRootRequest = new SearchRequest(string.Empty, "objectClass=*", SearchScope.Base, "rootDomainNamingContext"); var rootResponse = (SearchResponse)ldapConn.SendRequest(getRootRequest); var rootContext = rootResponse.Entries[0].Attributes["rootDomainNamingContext"][0].ToString(); // retrieve the user string ldapFilter = string.Format("(&amp;(objectCategory=person)(sAMAccountName={0}))", username); var getUserRequest = new SearchRequest(rootContext, ldapFilter, SearchScope.Subtree, null); var userResponse = (SearchResponse)ldapConn.SendRequest(getUserRequest); // send a new request to retrieve the tokenGroups attribute, we can not do this with our previous request since // tokenGroups needs SearchScope.Base (dont know why...) var tokenRequest = new SearchRequest(userResponse.Entries[0].DistinguishedName, "(&amp;(objectCategory=person))", SearchScope.Base, "tokenGroups"); var tokenResponse = (SearchResponse)ldapConn.SendRequest(tokenRequest); var tokengroups = tokenResponse.Entries[0].Attributes["tokenGroups"].GetValues(typeof(byte[])); // build query string this query will then look like (|(objectSid=sid)(objectSid=sid2)(objectSid=sid3)) // we need to convert the given bytes to a hexadecimal representation because thats the way they // sit in ActiveDirectory var sb = new StringBuilder(); sb.Append("(|"); for (int i = 0; i &lt; tokengroups.Length; i++) { var arr = (byte[])tokengroups[i]; sb.AppendFormat("(objectSid={0})", BuildHexString(arr)); } sb.Append(")"); // send the request with our build query. This will retrieve all groups with the given objectSid var groupsRequest = new SearchRequest(rootContext, sb.ToString(), SearchScope.Subtree, "sAMAccountName"); var groupsResponse = (SearchResponse)ldapConn.SendRequest(groupsRequest); // loop trough and get the sAMAccountName (normal, readable name) var userMemberOfGroups = new List&lt;string&gt;(); foreach (SearchResultEntry entry in groupsResponse.Entries) userMemberOfGroups.Add(entry.Attributes["sAMAccountName"][0].ToString()); return userMemberOfGroups; } private string BuildHexString(byte[] bytes) { var sb = new StringBuilder(); for (int i = 0; i &lt; bytes.Length; i++) sb.AppendFormat("\\{0}", bytes[i].ToString("X2")); return sb.ToString(); } </code></pre></li> </ul> <p>These are more for info purposes</p> <ul> <li><a href="http://support.microsoft.com/kb/297951" rel="noreferrer">How to use the PrimaryGroupID attribute to find the primary group for a user</a></li> <li><a href="http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%94Determining_User_Group_Membership_in_Active_Directory_and_ADAM" rel="noreferrer">Determining User Group Membership in Active Directory and ADAM</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload