Avatar billede jackass- Nybegynder
06. januar 2011 - 21:14 Der er 1 løsning

ifmember problem

Jeg får følgende fejl ved brug af "ifmember":

Error: Object required: 'objADObject'
Code: 800A01A8

Linien den melder fejl på er i nedenstående Function IfMember, denne linie:

If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then


Scriptet ser således ud:

--------------------------
Set objSysInfo         = CreateObject("ADSystemInfo")
strUserDN         = objSysInfo.UserName
strComputerDN         = objSysInfo.ComputerName
Set objUser         = GetObject("LDAP://" & strUserDN)
Set objComputer     = GetObject("LDAP://" & strComputerDN)

strUserDN         = Replace(strUserDN, "/", "\/")
strComputerDN         = Replace(strComputerDN, "/", "\/")

Function IsMember(ByVal objADObject, ByVal strGroup)
  ' Function to test for group membership.
  ' objGroupList is a dictionary object with global scope.
  If (IsEmpty(objGroupList) = True) Then
    Set objGroupList = CreateObject("Scripting.Dictionary")
  End If
  If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then
    Call LoadGroups(objADObject, objADObject)
    objGroupList.Add objADObject.sAMAccountName & "\", True
  End If
  IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" & strGroup)
End Function

Sub LoadGroups(ByVal objPriObject, ByVal objADSubObject)
  ' Recursive subroutine to populate dictionary object objGroupList.
  Dim colstrGroups, objGroup, j
  objGroupList.CompareMode = vbTextCompare
  colstrGroups = objADSubObject.memberOf
  If (IsEmpty(colstrGroups) = True) Then
    Exit Sub
  End If
  If (TypeName(colstrGroups) = "String") Then
    ' Escape any forward slash characters, "/", with the backslash
    ' escape character. All other characters that should be escaped are.
    colstrGroups = Replace(colstrGroups, "/", "\/")
    Set objGroup = GetObject("LDAP://" & colstrGroups)
    If (objGroupList.Exists(objPriObject.sAMAccountName & "\" & objGroup.sAMAccountName) = False) Then
      objGroupList.Add objPriObject.sAMAccountName & "\" & objGroup.sAMAccountName, True
      Call LoadGroups(objPriObject, objGroup)
    End If
    Set objGroup = Nothing
    Exit Sub
  End If
  For j = 0 To UBound(colstrGroups)
    ' Escape any forward slash characters, "/", with the backslash
    ' escape character. All other characters that should be escaped are.
    colstrGroups(j) = Replace(colstrGroups(j), "/", "\/")
    Set objGroup = GetObject("LDAP://" & colstrGroups(j))
    If (objGroupList.Exists(objPriObject.sAMAccountName & "\" & objGroup.sAMAccountName) = False) Then
      objGroupList.Add objPriObject.sAMAccountName & "\" & objGroup.sAMAccountName, True
      Call LoadGroups(objPriObject, objGroup)
    End If
  Next
  Set objGroup = Nothing
End Sub
-----------------------

Og jeg bruger den således:

If (IsMember(objUser, "Eksterne brugere") = True) Then
..do stuff..
End If


Nogen der kan hjælpe? :-/
Avatar billede jackass- Nybegynder
03. februar 2011 - 07:51 #1
.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester