I'm having an issue trying to enumerate the OU objects in AD. I found the following code that half works, but I'm apparently referencing the wrong item in the objItem object.
I'm getting back the correct number of items for the number of OU's that are children to the OU I'm connecting to, but there is no name in the popup window. So CN must not be the correct thing to reference to get the name of the child OU. Once I get the child OU name, I can just loop through that collection changing the GetObject function parameters to get the users in each one.
I guess a recursive function would be far more useful here, but I'm having a real issue doing some of this. Ideally I'd like to simply search AD to return data in such a way to build a treeview like this:
[Domain]
|
- [Organizational Unit]
|
- [User]
- [User]
- [Organizational Unit]
|
- [Organizational Unit]
|
- [User]
and so on.
What I'm attempting to do is write a script that will read in this data from AD, then retrieve various other tidbits of information, like server shares, printers (which I already have), then be able to set parameters at user level or OU level, and place these settings in a INI file (also done), which is then read from another script as a logon script (which is done). Right now I manually created the INI file, but I would like to make it so you don't have to edit it manually, but simply create these settings in an interface. Hopefully this explains what I'm trying to do and why I'm trying to do it.
Any help would be greatly appreciated. Thanks.
Code:
Set colItems = GetObject _
("LDAP://ou=Servers, dc=fabrikam, dc=com")
colItems.Filter = Array("organizationalUnit")
For Each objItem in colItems
Wscript.Echo objItem.CN
Next
I'm getting back the correct number of items for the number of OU's that are children to the OU I'm connecting to, but there is no name in the popup window. So CN must not be the correct thing to reference to get the name of the child OU. Once I get the child OU name, I can just loop through that collection changing the GetObject function parameters to get the users in each one.
I guess a recursive function would be far more useful here, but I'm having a real issue doing some of this. Ideally I'd like to simply search AD to return data in such a way to build a treeview like this:
[Domain]
|
- [Organizational Unit]
|
- [User]
- [User]
- [Organizational Unit]
|
- [Organizational Unit]
|
- [User]
and so on.
What I'm attempting to do is write a script that will read in this data from AD, then retrieve various other tidbits of information, like server shares, printers (which I already have), then be able to set parameters at user level or OU level, and place these settings in a INI file (also done), which is then read from another script as a logon script (which is done). Right now I manually created the INI file, but I would like to make it so you don't have to edit it manually, but simply create these settings in an interface. Hopefully this explains what I'm trying to do and why I'm trying to do it.
Any help would be greatly appreciated. Thanks.