vb.net array of ldap objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm writing a vb.net application to add new users to Active Directory 2003.
I am looking to find out if it is possible to store ldap objects in an array.
I have tried the following:

Dim Groups As Array =
Array.CreateInstance(GetType(DirectoryServices.DirectoryEntry), 5)

Then depending on which department the user is in, the code adds the groups
required to the array using the following code.

Groups.SetValue(GetObject("-ldap path to group here-"), gCtr)
gCtr = gCtr + 1

After getting all the groups the user should be in, I am using the following
code to try to add the user to the groups.

Dim i As Integer
Dim Group As DirectoryServices.DirectoryEntry
For i = 0 To Groups.Length - 1
Group = New DirectoryServices.DirectoryEntry(GetObject(Groups(i)))
Group.Invoke("Add", New Object() {"-ldap path to user here-"})
Group = Nothing
Next

When I run the program, I am getting an error on the first line where it
tries to add a group object to the "Groups" array. The error states that the
"Object cannot be stored in an array of this type."

Any help will be greatly appreciated.

Thanks,
 
Back
Top