| Author | Messages | |
Jeremy.Burkes.ctr@xxxx.yyy
 | | 11/30/2005 8:03 AM |
| 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 | | | |
| Jeremy.Burkes.ctr@xxxx.yyy
 | | 11/30/2005 8:07 AM |
| 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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Burkes, Jeremy [Contractor]
Sent: Wednesday, November 30, 2005
3: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 | | | |
| AD00000317
Posts:0
 | | 11/30/2005 8:24 AM |
| 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(";(&(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
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ | | | |
| ZJORZ
Posts:133
 | | 11/30/2005 8:27 AM |
| ________________________________
From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx on behalf of Burkes, Jeremy [Contractor]
Sent: Wed 11/30/2005 9:05 PM
To: ActiveDir@xxxxxxxxxxxxxxxxxx
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: ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Burkes, Jeremy [Contractor]
Sent: Wednesday, November 30, 2005 3: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
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
> | | | |
| Jeremy.Burkes.ctr@xxxx.yyy
 | | 11/30/2005 8:42 AM |
| Yeah I was trying to avoid ADO (Recordsets). I can
still use GetObject but must pull the OU, then search the OUfor the matching
username (pain). So I am using the GetObject(Winnt://). Thank you everyone
for the help.
Jeremy
From: Almeida Pinto,
Jorge de [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Almeida Pinto, Jorge de
Sent: Wednesday, November 30, 2005
3:14 PM
To: ActiveDir@xxxxxxxxxxxxxxxxxx
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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx on behalf of Burkes, Jeremy [Contractor]
Sent: Wed 11/30/2005 9:05 PM
To: ActiveDir@xxxxxxxxxxxxxxxxxx
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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Burkes, Jeremy [Contractor]
Sent: Wednesday, November 30, 2005
3: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 | | | |
| listmail
Posts:497
 | | 12/01/2005 2:03 AM |
| > 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?
It is
simply convention. The lDAPDisplayName is usually the cn of the schema
object stripped of hypens and the first letter lowercased.
As to why? I don't
have that info but if I thought about it I would say it was thought up by a
programmer, probably a c/c++ programmer. Most variable conventions in the
programming world set the first character of the variable lowercase or possibly
even the whole first set of characters which specify a var type like say obj or
int (or i for int) or str, etc. If truly interested I would say go do a google
for hungarian notation and Charles Simonyi.
joe From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx
[mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Steve
RochfordSent: Thursday, December 01, 2005 6:09 AMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: RE: [ActiveDir] _vbscript_ ADSI
IADs Get Method
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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Almeida Pinto, Jorge deSent: 30 November 2005
20:14To: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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 =
oConnectionsQuery = "SELECT DistinguishedName FROM 'LDAP://" &
sDomainDNSW2Kx & "' WHERE sAMAccountName = '" & ssAMAccountName &
"'"oCommand.CommandText = sQuerySet oResults =
oCommand.ExecutesObjDN = oResults.Fields("DistinguishedName")
-------------------------------------------------------------------
cheers,
Jorge
From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx on
behalf of Burkes, Jeremy [Contractor]Sent: Wed 11/30/2005 9:05
PMTo: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Burkes, Jeremy
[Contractor]Sent: Wednesday,
November 30, 2005 3:02 PMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: [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
BurkesSystem Analyst/MIS SPHQjeremy.burkes.ctr@xxxxxxxxxxxxPH:
202-764-1270 Fax: 202-764-1503 | | | |
| alainlissoir
Posts:3
 | | 12/01/2005 3:33 AM |
| If you want
more ADSI explanations and samples, you can have a look at the White Paper
section at http://www.lissware.net.
HTH
/Alain From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx
[mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of
joeSent: Thursday, December 01, 2005 6:01 AMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: RE: [ActiveDir] _vbscript_ ADSI
IADs Get Method
> 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?
It is
simply convention. The lDAPDisplayName is usually the cn of the schema
object stripped of hypens and the first letter lowercased.
As to why? I don't
have that info but if I thought about it I would say it was thought up by a
programmer, probably a c/c++ programmer. Most variable conventions in the
programming world set the first character of the variable lowercase or possibly
even the whole first set of characters which specify a var type like say obj or
int (or i for int) or str, etc. If truly interested I would say go do a google
for hungarian notation and Charles Simonyi.
joe From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx
[mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx] On Behalf Of Steve
RochfordSent: Thursday, December 01, 2005 6:09 AMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: RE: [ActiveDir] _vbscript_ ADSI
IADs Get Method
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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Almeida Pinto, Jorge deSent: 30 November 2005
20:14To: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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 =
oConnectionsQuery = "SELECT DistinguishedName FROM 'LDAP://" &
sDomainDNSW2Kx & "' WHERE sAMAccountName = '" & ssAMAccountName &
"'"oCommand.CommandText = sQuerySet oResults =
oCommand.ExecutesObjDN = oResults.Fields("DistinguishedName")
-------------------------------------------------------------------
cheers,
Jorge
From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx on
behalf of Burkes, Jeremy [Contractor]Sent: Wed 11/30/2005 9:05
PMTo: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Burkes, Jeremy
[Contractor]Sent: Wednesday,
November 30, 2005 3:02 PMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: [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
BurkesSystem Analyst/MIS SPHQjeremy.burkes.ctr@xxxxxxxxxxxxPH:
202-764-1270 Fax: 202-764-1503 | | | |
| SteveRochford
Posts:10
 | | 12/01/2005 11:13 AM |
| 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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Almeida Pinto, Jorge deSent: 30 November 2005
20:14To: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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 =
oConnectionsQuery = "SELECT DistinguishedName FROM 'LDAP://" &
sDomainDNSW2Kx & "' WHERE sAMAccountName = '" & ssAMAccountName &
"'"oCommand.CommandText = sQuerySet oResults =
oCommand.ExecutesObjDN = oResults.Fields("DistinguishedName")
-------------------------------------------------------------------
cheers,
Jorge
From: ActiveDir-owner@xxxxxxxxxxxxxxxxxx on
behalf of Burkes, Jeremy [Contractor]Sent: Wed 11/30/2005 9:05
PMTo: ActiveDir@xxxxxxxxxxxxxxxxxxSubject: 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:
ActiveDir-owner@xxxxxxxxxxxxxxxxxx [mailto:ActiveDir-owner@xxxxxxxxxxxxxxxxxx]
On Behalf Of Burkes, Jeremy
[Contractor]Sent: Wednesday,
November 30, 2005 3:02 PMTo:
ActiveDir@xxxxxxxxxxxxxxxxxxSubject: [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
BurkesSystem Analyst/MIS SPHQjeremy.burkes.ctr@xxxxxxxxxxxxPH:
202-764-1270 Fax: 202-764-1503
|
|
|