none
Error calling Principal.GetAuthorizationGroups RRS feed

  • Question

  • Using the following code I am getting the error "An error occurred while enumerating the groups. The group could not be found" while enumerating the groups. I've looked around and can't find much about this error other than a couple of people who have also experienced it.

        using (PrincipalContext context = new PrincipalContext(ContextType.Domain , "DOMAIN", "DOMAIN\\USER", "PW"))
    	        {
    		        try
    		        {
    			    //Create a referance to the user account we are querying
                               //against.
    			        UserPrincipal p = UserPrincipal.FindByIdentity(context,
                                            username);
    			        //Get the user's security groups.  This is necessary to
                                       //return nested groups, but will NOT return distribution groups.
    			        PrincipalSearchResult <Principal> groups  = p.GetAuthorizationGroups();
    			        foreach (GroupPrincipal group in groups)
    			        {
    					        results.Add(group.SamAccountName);
            							
    			        }
    		        }
    		        catch (Exception ex)
    		        {
    			        throw new Exception(
                                           "Unable to query Active Directory.", ex);
    		        }
    	        }
    Tuesday, December 29, 2009 4:51 PM

Answers

  • Hi,

    I'm writing to confirm with you that if your system is Windows XP SP3, because there is a known issue for WinXP SP3, and the product team is investigating it.

    Looks like it is failing because of the reason mentioned in http://support.microsoft.com/kb/931211/en-us , which throws ERROR_MORE_DATA error on WinXP SP3. When installed SP3, it started failing with 'NoMatchingPrincipalException' - the group could not be found error.

     

    I was able to reproduce the issue you are seeing. I have reported a feedback through Visual Studio & .NET Connect site:

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=522539 

    This issue will be routed to the product unit who works on this specific feature area for triage and resolution. I’ll paste all responses from the product unit in this thread. And you also can click the link and add the feedback to your watchlist ( you need to log in using your account) so that you can get informed as soon as product units respond.  It may be some time before we get response from product unit. Please be patient.


    Sincerely,
    Eric

    Please remember to mark helpful replies as answers.
    • Marked as answer by eryang Friday, January 8, 2010 3:12 AM
    Wednesday, December 30, 2009 9:07 AM

All replies

  • Hi,

    I'm writing to confirm with you that if your system is Windows XP SP3, because there is a known issue for WinXP SP3, and the product team is investigating it.

    Looks like it is failing because of the reason mentioned in http://support.microsoft.com/kb/931211/en-us , which throws ERROR_MORE_DATA error on WinXP SP3. When installed SP3, it started failing with 'NoMatchingPrincipalException' - the group could not be found error.

     

    I was able to reproduce the issue you are seeing. I have reported a feedback through Visual Studio & .NET Connect site:

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=522539 

    This issue will be routed to the product unit who works on this specific feature area for triage and resolution. I’ll paste all responses from the product unit in this thread. And you also can click the link and add the feedback to your watchlist ( you need to log in using your account) so that you can get informed as soon as product units respond.  It may be some time before we get response from product unit. Please be patient.


    Sincerely,
    Eric

    Please remember to mark helpful replies as answers.
    • Marked as answer by eryang Friday, January 8, 2010 3:12 AM
    Wednesday, December 30, 2009 9:07 AM
  • Eric,

        Thanks, yes I am running on XP SP3. In the mean time I have access to a system running server 2003 with Visual Studio installed, I will give it a try there since that is the operating system the code will be running on in production.

    Thanks
    Bill
    Wednesday, December 30, 2009 8:49 PM
  • Hi Bill,
    How about the test result in the Windows Server 2003 environment?
    Sincerely,
    Eric

    Please remember to mark helpful replies as answers.
    Monday, January 4, 2010 1:51 AM
  • Eric,

        I posted to the support site but forgot to post to this one. This didn't work either, I encountered the same error.

    Bill
    Monday, January 4, 2010 3:19 AM