Hi

I am new to VBscript and would like to be able to query an OU for it's
contents (which is more OU's) and then display the results in the text
field on an inputbox. This is so that the user can enter the name of
one of the OU's listed into the inputbox input field.

Hope this makes sense.

Thanks in advance
Keith

Re: List OU's in an OU using VBS by Richard

Richard
Wed Jul 20 10:51:17 CDT 2005


<keith.gibson@luton.gov.uk> wrote in message
news:1121870718.758293.149680@z14g2000cwz.googlegroups.com...
> Hi
>
> I am new to VBscript and would like to be able to query an OU for it's
> contents (which is more OU's) and then display the results in the text
> field on an inputbox. This is so that the user can enter the name of
> one of the OU's listed into the inputbox input field.

Hi,

The simplest way is to bind to the OU, filter on the class of child objects
you want (OU's) and enumerate. For example:

Set objOU = GetObject("LDAP://ou=Sales,dc=MyDomain,dc=com")
objOU.Filter = Array("organizationalUnit")
strList = "Select an Organizational Unit:"
For Each objChild In objOU
strList = strList & vbCrLf & objChild.ou
Next
strSelect = InputBox(strList, "MyProgram")

You can use "distinguishedName", "Name" (relative distinguished name), or
"ou" to identify the OU. You could also use ADO to query for this
information, but the above is more straightforward.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--



Re: List OU's in an OU using VBS by keith

keith
Thu Jul 21 03:09:27 CDT 2005

Many thanks Richard, that worked a treat

Thanks again
Keith

Richard Mueller [MVP] wrote:
> <keith.gibson@luton.gov.uk> wrote in message
> news:1121870718.758293.149680@z14g2000cwz.googlegroups.com...
> > Hi
> >
> > I am new to VBscript and would like to be able to query an OU for it's
> > contents (which is more OU's) and then display the results in the text
> > field on an inputbox. This is so that the user can enter the name of
> > one of the OU's listed into the inputbox input field.
>
> Hi,
>
> The simplest way is to bind to the OU, filter on the class of child objects
> you want (OU's) and enumerate. For example:
>
> Set objOU = GetObject("LDAP://ou=Sales,dc=MyDomain,dc=com")
> objOU.Filter = Array("organizationalUnit")
> strList = "Select an Organizational Unit:"
> For Each objChild In objOU
> strList = strList & vbCrLf & objChild.ou
> Next
> strSelect = InputBox(strList, "MyProgram")
>
> You can use "distinguishedName", "Name" (relative distinguished name), or
> "ou" to identify the OU. You could also use ADO to query for this
> information, but the above is more straightforward.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --