Here is an easy wayfor ADOregular bind at the bottom, mind the wrap:
On Error Resume Next
set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADSDSOObject"
oConn.Open("ADs Provider")
set oRs =
oConn.Execute("<LDAP://server.domain.com/DC=domain,DC=com>;(&(objectClas
s=user)(objectClass=person));ADsPath,displayName,mail,sAMAccountName,pho
neNumber;subtree")
while Not oRs.EOF
set obj = GetObject(oRs.Fields("ADsPath").Value)
If obj.sAMAccountName = "Not me" Then
oRs.MoveNext()
Else
WScript.Echo(obj.sAMAccountName + " <- This is me")
oRs.MoveNext()
End If
wend
oConn.Close()
Here is the normal bind way, again mind the wrap:
(From one of Robbie's scripts I believe, correct me if I am wrong)
Dim DSO as IADsOpenDSObject
Set DSO = GetObject('LDAP:')
Dim User as IADsUser
Set User =
DSO.OpenDSObject('LDAP://cn=juser,ou=Accounts,dc=domain,dc=com','adminis
trator@xxxxxxxxxx','guessmypass',0)
From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx
[mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Burkes, Jeremy
[Contractor]
Sent: Wednesday, November 30, 2005 1:02 PM
To: ActiveDir@xxxxxxxxxxxxxxxxxx
Subject: [ActiveDir] VBSCRIPT ADSI IADs Get Method
Everyone,
I am trying to write a vbscript to connect to a user account
using the samaccountname attribute to update some info. Is this even
possible and if so can someone provide a code sample, I would think it
would look something like this for Test in the Microsoft domain:
LDAP://sAMAccountName=Test, OU=Users,DC=Microsoft,DC=COM or
LDAP://sAMAccountName=Test,CN=Users,DC=Microsoft,DC=COM
Then again, maybe this is not even possible. If not should
I use ADO instead even though I am returning 1 record with each query,
seems inefficient way to me when I can just use an ADSI pointer.
Jeremy
--------------------------
Jeremy Burkes
System Analyst/MIS SPHQ
jeremy.burkes.ctr@xxxxxxxxxxxx
PH: 202-764-1270 Fax: 202-764-1503
|