Re: How to bind to user object without knowing the path
From: Markko Meriniit (zork_at_moomin.ee)
Date: 05/27/04
- Previous message: Arwoot K.: "Re: New user"
- In reply to: Niclas Lindblom: "Re: How to bind to user object without knowing the path"
- Next in thread: Matt Hickman: "Re: Help: How to bind to user object without knowing the path"
- Messages sorted by: [ date ] [ thread ]
Date: 27 May 2004 02:24:31 -0500
"Niclas Lindblom" <nospam.lindblom_niclas@hotmail.com> wrote in message
news:OtQte0yQEHA.3016@tk2msftngp13.phx.gbl...
> I am not aware of any other way of searching the directory using VB script
> than using ADO. Below is a function that will take a samaccountname as
input
> and return the distinguishedname that you then can bind with LDAP.
You are right, GetObject binds you to specified object and you can't use
LDAP search query syntax in GetObject function, imho.
> '##SCRIPT START
>
> set oUser=getobject("LDAP://" & ReturnDN("myUserSamAccountName"))
>
>
> Function ReturnDN(SamAccountName)
> 'Your domain root goes here (could extract using ROOTDSE)
> sDomain="DC=myDomain,DC=com"
> Set oAdoConnection = CreateObject("ADODB.Connection")
> oAdoConnection.Provider = "ADsDSOObject"
> oAdoConnection.Open ""
>
> Set oAdoRecordset = oAdoConnection.Execute _
> ("<LDAP://"& sDomain &">;(objectClass=User);" _
> & "SamAccountName,DistinguishedName;SubTree")
I let the LDAP query to do work for myself:
Set oAdoRecordset = oAdoConnection.Execute _
("<LDAP://"& sDomain &">;(&(SamAccountName=" & SamAccountName &
")(objectClass=User));" _
& "SamAccountName,DistinguishedName;SubTree")
oAdoConnection.close
End Function
Markko
- Previous message: Arwoot K.: "Re: New user"
- In reply to: Niclas Lindblom: "Re: How to bind to user object without knowing the path"
- Next in thread: Matt Hickman: "Re: Help: How to bind to user object without knowing the path"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|