How can I view OU's using adsi and asp

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
nav007_2000
Posts: 3
Joined: Thu May 24, 2007 12:39 am

How can I view OU's using adsi and asp

Post by nav007_2000 » Thu May 24, 2007 12:47 am

Hello all,I have created a web page that allows me to add new users to active directory. at the moment all new users go to the default ou called users. I would like to create a drop down menu that allows me to choose what OU I want to place them into. How can I create this drop down list to show all the OU's in my domain?
Regards
Nav

User avatar
nav007_2000
Posts: 3
Joined: Thu May 24, 2007 12:39 am

How can I view OU's using adsi and asp

Post by nav007_2000 » Thu May 24, 2007 12:47 am

Hello all,I have created a web page that allows me to add new users to active directory. at the moment all new users go to the default ou called users. I would like to create a drop down menu that allows me to choose what OU I want to place them into. How can I create this drop down list to show all the OU's in my domain?
Regards
Nav

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

How can I view OU's using adsi and asp

Post by donj » Thu May 24, 2007 3:06 am

There are a few ways to do that. I'm assuming you know how to create a drop-down list in HTML, and so what you're after is a way to retrieve all the OU names from the domain.

On the Essentials page of this site, you'll find a script that enumerates users and computers. Well, it also enumerates OUs. So, in the bit of the script that gets an OU name, you would just add the OU to your drop-down list.

User avatar
nav007_2000
Posts: 3
Joined: Thu May 24, 2007 12:39 am

How can I view OU's using adsi and asp

Post by nav007_2000 » Thu May 24, 2007 6:54 pm

Thanks for that. I will have a look at it.
I can create a static drop down list in HTML, how do I make it dynamic using the code below?

WorkWithObject oDomain
Sub DoObject_User(strName) 'your code goes here - strName 'is a user name. If you don't care 'about users, just leave this empty.End Sub
Sub DoObject_Computer(strName)
'your code goes here - strName 'is a computer name. If you don't care 'about computers, just leave this empty.End Sub
Sub WorkWithObject(oContainer) Dim oADObject For Each oADObject in oContainer Select Case oADObject.Class Case "user" 'oADObject represents a USER object; 'do something with it
DoObject_User oADObject.cn Case "computer" 'oADObject represents a COMPUTER object; 'do something with it DoObject_Computer oADObject.cn Case "organizationalUnit" , "container" 'oADObject is an OU or container... 'go through its objects WorkWithObject(oADObject) End select NextEnd Sub

Locked