Re: How to bind to user object without knowing the path

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Markko Meriniit (zork_at_moomin.ee)
Date: 05/27/04

  • Next message: Roland Hall: "Re: Is it possible to invoke the browse for user object through vbscript?"
    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


  • Next message: Roland Hall: "Re: Is it possible to invoke the browse for user object through vbscript?"

    Relevant Pages

    • Re: Can LDAP API be used either from VB or VBScript ?
      ... "Fie Fie Niles" wrote in message ... When I read about LDAP, ... we can use ADO for that? ... ADO is used for searching so you probably will need only the ADSI objects; ...
      (microsoft.public.vb.general.discussion)
    • Using system Select Users, Computers or Groups dialog box.....
      ... does anybody using system 'Select Users, Computers or Groups' dialog box ... to searching in LDAP? ... I use my own dialog for this purpose but using the system one is much ...
      (microsoft.public.dotnet.languages.csharp)
    • SLow LDAP Response
      ... I have several copmuters that are receiving a very slow, ... response from the LDAP when searching ...
      (microsoft.public.outlook)
    • Re: Windows Users
      ... I need local users. ... > searching for LDAP in this newsgroup. ...
      (microsoft.public.dotnet.languages.vb)