Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ldap and active directory

Status
Not open for further replies.

cptkirkh

MIS
Feb 20, 2001
95
US
I seem to be having problems. I want to pull a list of groups that a particular user has listed and then map drives to that user according to group membership. I want to write one script for my whole company. This script will base it's search on the login name. Well when i do an ldap search on login name it says no such object exists. Yet when i hard code the Full name it works see example below. I would really appreciate some help. Thanks in advance. I have to hard code John Doe but i would rather use login name of the client pc.

Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D

Set objUser = GetObject _
("LDAP://cn=John Doe,ou=MIS,dc=xyz,dc=wxyz,dc=com")

intPrimaryGroupID = objUser.Get("primaryGroupID")
arrMemberOf = objUser.GetEx("memberOf")

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "The memberOf attribute is not set."
Else
WScript.Echo "Member of: "
For each Group in arrMemberOf
WScript.Echo Group
Next
End If

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
&quot;<LDAP://dc=xyz,dc=wxyz,dc=com>;(objectCategory=Group);&quot; & _
&quot;distinguishedName,primaryGroupToken;subtree&quot;
Set objRecordSet = objCommand.Execute

While Not objRecordset.EOF
If objRecordset.Fields(&quot;primaryGroupToken&quot;) = intPrimaryGroupID Then
WScript.Echo &quot;Primary group:&quot;
WScript.Echo objRecordset.Fields(&quot;distinguishedName&quot;) & _
&quot; (primaryGroupID: &quot; & intPrimaryGroupID & &quot;)&quot;
End If
objRecordset.MoveNext
Wend

objConnection.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top