Title: Message
I've done this kind of thing but (as Jeremy has said) it seems really inefficient to have to make all those calls.
 
As an example, suppose I have a list of students whose accounts I want to deactivate. I'll get that as a list of sAMAccountNames (because the student ID number is used for their username). I now need to query active directory to get the distinguishedname and then bind to that object to do things to it.
 
For some purposes I know I can use getobject("WinNT://domain/samaccountname") but that isn't always suitable. What I want is something which allows me to specify the sAMAccountName in the LDAP: string.
 
As a complete aside, is there a reason for the odd capitalisation which always seems to be used for sAMAccountName? SAMAccountName would seem much better?
 
Steve
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Almeida Pinto, Jorge de
Sent: 30 November 2005 20:14
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] _vbscript_ ADSI IADs Get Method

It is possible... you only have to do it another way...
query AD for the object that matches a certain sAMAccountName
-------------------------------------------------------------------
sDomainDNSW2Kx = "ADCORP.LAN"
ssAMAccountName = "JORGE"
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
Set oCommand.ActiveConnection = oConnection
sQuery = "SELECT DistinguishedName FROM 'LDAP://" & sDomainDNSW2Kx & "' WHERE sAMAccountName = '" & ssAMAccountName & "'"
oCommand.CommandText = sQuery
Set oResults = oCommand.Execute
sObjDN = oResults.Fields("DistinguishedName")
-------------------------------------------------------------------
cheers,
Jorge


From: [EMAIL PROTECTED] on behalf of Burkes, Jeremy [Contractor]
Sent: Wed 11/30/2005 9:05 PM
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] _vbscript_ ADSI IADs Get Method

Nevermind, just found the answer to my own question, and it is no, must use the persons CN, no other attributes are accepted, good to know.  Thanks for the potential help.

 

Jeremy

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Burkes, Jeremy [Contractor]
Sent: Wednesday, November 30, 2005 3:02 PM
To: ActiveDir@mail.activedir.org
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
[EMAIL PROTECTED]
PH: 202-764-1270 Fax: 202-764-1503

 

Reply via email to