docusnap-dude
Goto Top

VBscripting ifmembership

VBscripting

Hallo,

ich habe je eine Active Directory-Gruppe "ReportReaders" sowie "Reporteditors.

In jeder dieser gruppen sind keine Einzeluser sondern auch Gruppen enthalten. Das heisst: in "Reportreaders" sind die Mitglieder nicht Müller, Meyer, Schulze sondern z.B. "Einkauf", "Buchhaltung", "Verkauf" enthalten.

meine Frage:

ich möchte im Login abfragen erstellen, welche einen user als Mitglied der "ReportReaders" identifizeiren um dann weitere Schritte zu machen. Ich mache das im VBscript wie folgt (Auszüge):

...
if isMember("Reportreaders") then  
     '...tu dies  
    '...mach das  
   '...tu jenes  
End If

'## Functions ##  
	'##isMember##  
		Function IsMember(sGroup)
    		Dim sAdsPath, oUser, oGroup
	    		If IsEmpty(oGroupDict) Then
        			Set oGroupDict = CreateObject("Scripting.Dictionary")  
        			oGroupDict.CompareMode = vbTextCompare
        			sAdsPath = WshNetwork.UserDomain & "/" & WshNetwork.UserName  
        			Set oUser = GetObject("WinNT://" & sAdsPath & ",user")  
 		        	For Each oGroup In oUser.Groups
            			oGroupDict.Add oGroup.Name, "-"  
        			Next
        			Set oUser = Nothing
    			End If
    		IsMember = CBool(oGroupDict.Exists(sGroup))
	End Function

Mein problem: es klappt nicht. Ursache ist, das mein script nicht in die die "Subgroups" schaut sondern eben nur ob direkt in der Gruppe "ReportReaders" ein Müller ist.

Hat da einer eine machbare variante?

Danke für eure Hilfe

Frank

Content-Key: 155784

Url: https://administrator.de/contentid/155784

Printed on: April 16, 2024 at 09:04 o'clock

Member: bastla
bastla Nov 25, 2010 at 14:33:29 (UTC)
Goto Top
Hallo frankoehli!

Wäre ich ein "Scripting Guy" würde ich wohl sagen: "Been there, done that ..." face-wink

Grüße
bastla