none
DirectoryServices GetAuthorizationGroups() not recursively finding all groups RRS feed

  • Question

  • MSDN says that the GetAuthorizationGroups() "...searches all groups recursively and returns the groups in which the user is a member. The returned set may also include additional groups that system would consider the user a member of for authorization purposes."

    I am not getting the results that I am expecting, because GetGroups() is returning a lot more groups than GetAuthorizationGroups(). Am I missing a configuration or misunderstanding what GetAuthorizationGroups() is supposed to do?

    Thanks,

    Ed

    public static ArrayList GetGroupNamesBySID(string userName) { string groupDomain; var winGroups = newArrayList(); string searchString = string.Format("DC={0},DC=domain,DC=net""AMERICAS"); PrincipalContext principalContext = newPrincipalContext(ContextType.Domain, "AMERICAS", searchString, "user""password"); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, userName); try { PrincipalSearchResult<Principal> result = userPrincipal.GetAuthorizationGroups(); foreach (Principal group in result) { GroupPrincipal groupPrincipal = (GroupPrincipal)group; groupPrincipal.GetMembers(); winGroups.Add(group.Name); } } catch (Exception ex) { Trace.WriteLine("Error: " + ex.Message); Trace.WriteLine("InnerException: " + ex.InnerException); } return winGroups; }

    I just noticed I am among many other OP'ers that ran into the NoMatchingPrincipalException.

        

    • Edited by advantage_ed Thursday, February 28, 2013 10:24 PM
    Thursday, February 28, 2013 9:41 PM

Answers