query OU from AD

query OU from AD

Post by weiw » Mon, 14 Oct 2002 04:20:11



someone in the board give me some hints, however, I still not quite
understand, I need some script example, please. thanks
Wei

You will have to set up three separate searches with the three bases
you
have indicated. You can not exclude a certain branch from the search
when
searching at a higher level.

I.E.

You need one search with a search base at the ame ou
You need one search with a search base at the amd ou
You need one search with a search base at the bad ou

--
Joe Richards
www.joeware.net
---


Quote:> Hi,
> I am trying to OU from AD in vbscript, for example,
> ou=office,
>     ou = ame
>        ou = administrator
>        ou = teacher
>     ou = amd
>     ou = bad

> my current script can show the all OUs, but what i want is only show
> OU=ame, ou=amd, ou=bad, I don't want those nest ou under ame, amd, and
> bad, does anyone have some idea to help me out?
> thanks in advance
> Wei

> below is my script
> Dim Result
> Dim Connection
> Dim rs
> Dim strSiteCN

> Set Connection = CreateObject("ADODB.Connection")
> Connection.Provider = "ADsDSOObject"
> Connection.Open "ADs Provider"

> strSQL = "SELECT distinguishedname FROM
> 'LDAP://ou=Offices,DC=child,DC=dev,DC=ORG' WHERE ObjectCategory =
> 'organizationalunit'"

> Set objRS = CreateObject("ADODB.Recordset")
> 'objRS.CursorLocation = adUseClient
> 'objRS.CursorLocation = 3 'adUserClint
> objRS.Open strSQL, Connection

> aIndex = 0
> Do While Not objRS.EOF

> ' Make sure the subnet is associated with a Site
> If Not IsNull(objRS.Fields("distinguishedname")) Then
> strSiteCN = objRS.Fields("distinguishedname")

> msgbox strSiteCN

> End If
> objRS.MoveNext
> Loop
> objRS.Close

 
 
 

1. query ou from AD

Hi,
I am trying to OU from AD in vbscript, for example,
ou=office,
    ou = ame
       ou = administrator
       ou = teacher
    ou = amd
    ou = bad

my current script can show the all OUs, but what i want is only show
OU=ame, ou=amd, ou=bad, I don't want those nest ou under ame, amd, and
bad, does anyone have some idea to help me out?
thanks in advance
Wei

below is my script
Dim Result
Dim Connection
Dim rs
Dim strSiteCN

Set Connection = CreateObject("ADODB.Connection")
Connection.Provider = "ADsDSOObject"
Connection.Open "ADs Provider"

strSQL = "SELECT distinguishedname FROM
'LDAP://ou=Offices,DC=child,DC=dev,DC=ORG' WHERE ObjectCategory =
'organizationalunit'"

Set objRS = CreateObject("ADODB.Recordset")
'objRS.CursorLocation = adUseClient
'objRS.CursorLocation = 3 'adUserClint
objRS.Open strSQL, Connection

aIndex = 0
Do While Not objRS.EOF

' Make sure the subnet is associated with a Site
If Not IsNull(objRS.Fields("distinguishedname")) Then
strSiteCN = objRS.Fields("distinguishedname")

msgbox strSiteCN

End If
objRS.MoveNext
Loop
objRS.Close

2. Keyword Idioms

3. Upgrade / Reinstall SMS 2.0 into OU of AD Domain

4. Palm Pilot V

5. AD OU Browse Dialog

6. texas instruments C6x

7. vbscript to mass add users to an AD OU

8. AppleSoft Basic Question

9. Read Server,OU etc from AD

10. Modifying AD Attribute for Users within an OU

11. Query limited to computers within an OU

12. LDAP Query for Multiple OU's

13. can we query user from OU