.NET Framework Developer Center > .NET Development Forums > .NET Base Class Library > UserPrincipal.GetAuthorizationGroups problem
Ask a questionAsk a question
 

QuestionUserPrincipal.GetAuthorizationGroups problem

  • Thursday, November 05, 2009 10:07 PMNiwomph Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    I am having a rather perplexing problem with UserPrincipal.GetAuthorizationGroups.

    My C# Winforms client contains the following code:

    string identity=@"XYZ\A";
    PrincipalContext context = new PrincipalContext(ContextType.Domain);
    UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, identity);
    PrincipalSearchResult<Principal> groups = userPrincipal.GetAuthorizationGroups();

    When I run the application on my workstation (Windows XP), running under my account XYZ\A, this code works fine.  The code will also correctly retrieve the groups for another user, user XYZ\B, when the application runs under my NT account.

    However, when the application is deployed to XYZ\Bs workstation the code fails with the following exception:

    An error occurred while enumerating the groups. The group could not be found.

    The bottom of the stack trace on the exception is:

    at System.DirectoryServices.AccountManagement.AuthZSet.get_CurrentAsPrincipal()
    at System.DirectoryServices.AccountManagement.FindResultEnumerator`1.get_Current()

    To rule out any potential differences between workstations, I logged onto our Terminal Services box, and XYZ\B did the same. The result was as above i.e. I could retrieve permissions for both XYZ\A and XYZ\B whereas XYZ\B recieved the exception in both cases.

    I had our IT team clone XYZ\B, producing XYZ\C. XYZ\C could retrieve permissions for all three users.

    One thing that the users that are experiencing this problem have in common is that were originally added to our AD installation using a bulk load script, rather than being created manually. Other users do not experience the problem.

    Any suggestions welcome.