Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

primaryGroupID with index out of range errors.

Last post 09-16-2010, 8:03 PM by dunnry. 2 replies.
Sort Posts: Previous Next
  •  08-12-2010, 2:44 PM 8509

    primaryGroupID with index out of range errors.

    I can get the primaryGroupID but when it goes to display it on a console application, it decides that it's too good for me. Rolling out an Index out of range etc etc. Which means the ID is unhandled. The thing is that it's been so long since I have done an array to make it so these things are readable and I can't find anything online to help me remember.

    [Code]

    Dim Results As SearchResultCollection = objSearch.FindAll()

    Dim objpgID As Integer

    For Each Result As SearchResult In Results

    objpgID = Result.Properties("primaryGroupID").Item(0)

    Console.WriteLine(objpgID)

    Console.WriteLine(Result.Path)[/Code]

    This is in a try catch to handle the exceptions.


    I like stuff and it has a lot to do with how I do.
  •  09-02-2010, 3:59 AM 8532 in reply to 8509

    Re: primaryGroupID with index out of range errors.

    That should work - the only reason I can think of why it might not work is if you have not added the primaryGroupID attribute to the list of properties to be loaded by the directory searcher. E.g:

    Dim Searcher As New DirectorySearcher
    Searcher.PropertiesToLoad.Add("primaryGroupID")
    My website: cjwdev.co.uk
    My blog: cjwdev.wordpress.com
  •  09-16-2010, 8:03 PM 8551 in reply to 8532

    Re: primaryGroupID with index out of range errors.

    I suppose it is possible that the user in question does not have a primary group, but that would be strange.


    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
View as RSS news feed in XML