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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Groups in AD

Status
Not open for further replies.

RNF0528

MIS
Apr 4, 2006
115
US
I am running into an error while using the LoadGroups Function. ANy help would be great...

The code is below.-------------------------------------------------------------------------------------------

Function IsMember(objADObject, strGroup)
' Function to test for group membership.
' objGroupList is a dictionary object with global scope.

If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
End If
If Not objGroupList.Exists(objADObject.sAMAccountName & "\") Then
Call LoadGroups(objADObject, objADObject)
objGroupList(objADObject.sAMAccountName & "\") = True
End If
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroup)
End Function

Sub LoadGroups(objPriObject, objADSubObject)
' Recursive subroutine to populate dictionary object objGroupList.

Dim colstrGroups, objGroup, j

objGroupList.CompareMode = vbTextCompare
colstrGroups = objADSubObject.memberOf
If IsEmpty(colstrGroups) Then
Exit Sub
End If
If TypeName(colstrGroups) = "String" Then
Set objGroup = GetObject("LDAP://" & colstrGroups)
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Set objGroup = Nothing
Exit Sub
End If
For j = 0 To UBound(colstrGroups)
Set objGroup = GetObject("LDAP://" & colstrGroups(j))
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Next
Set objGroup = Nothing
End Sub

-----------------------------------------------------------------


The error i am getting is...Microsoft VBScript runtime error: Object required: 'objADObject'
 
Is this all your code? Where do you define objADObject that you pass into you IsMember Function?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
He is a snippet of what I am tring to accomplish.

code--------------------------------------------------------

Dim objGroupList, objUser, objFSO, WshShell, objADObject
Set objADObject = CreateObject("WScript.Shell")

If IsMember(objUser, "Test-DBA01-SWIM") Then
WshShell.Run "net use H: /d /y", 0, True
objNet.MapNetworkDrive "H:", "\\DBA01\SWIM$"
End If

 
And now I am getting this error-----------


Object doesn't support this property or method: 'objADObject.sAMAccountName'
 
Where did you get the code you're trying? You're missing something and this line

Set objADObject = CreateObject("WScript.Shell")

can not be what the function is looking for...it should be something like

Set objADObject = GetObject("LDAP://xxxxxxx")

This looks like a login script...see the FAQ by Mark here:
--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Wow, trying to follow the logic of the above samples but they are not making much sense. What is it you are trying to do?

I agree with dm4ever in that it looks like you are trying to do something with group memberships possibly as part of a login script. As dm4ever has pointed out, you will probably find what you need in my FAQ, but if you do not then please post back what your end goal is here.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top