Une fonction VBS pour vérifier la présence d’un utilisateur dans un groupe Active Directory
La fonction renvoie True ou False
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Function IsMember(groupName, UserName) If IsEmpty(groupListD) then Set groupListD = CreateObject("Scripting.Dictionary") groupListD.CompareMode = 1 ADSPath = EnvString("userdomain") & "/" & UserName On error resume next Set userPath = GetObject("WinNT://" & ADSPath & ",user") If err.number <> 0 Then IsMember = False Else For Each listGroup in userPath.Groups groupListD.Add listGroup.Name, "-" Next End If On Error Goto 0 End if IsMember = CBool(groupListD.Exists(groupName)) End Function |
Cet article n'a pas été revu depuis la publication.
Cet article a été créé par david le 27 décembre 2016.
Laisser un commentaire