Quote:
Break ON

$objSysInfo = CreateObject("ADSystemInfo")

? "User is a member of the following: "
For Each $sGroup in GetGroups("LDAP://"+$objSysInfo.username,">")
? $sGroup
Next

@CRLF
@CRLF
@CRLF
@CRLF

$group = "GG_BRSP03017A_EMPRESA_MAP_DRIVE"

If InGroup($group)
? "member"
;Map drive
Else
? "not a member"
;Do not map drive
EndIf

@CRLF
@CRLF
@CRLF
@CRLF

;"Computer is a member of the following: "+@CRLF
;For Each $sGroup in GetGroups("LDAP://"+$objSysInfo.computername,">")
; $sGroup+@CRLF
;Next




Function GetGroups($vStart,Optional $sIndent)
Dim $sGroupList, $sGroup
If Not (9 = VarType($vStart)) $vStart=GetObject($vStart) EndIf
If Not (9 = VarType($vStart)) Exit 87 EndIf

$sGroupList=$vStart.GetEx("memberOf")
If @ERROR Exit 0 EndIf
For Each $sGroup in $sGroupList
If Not(ASCan($GetGroups,$sGroup)+1) OR $sIndent
$GetGroups=Split(Join($GetGroups,Chr(10))+Chr(10)+SubStr($sIndent,2)+$sGroup,Chr(10))
EndIf
For Each $sChain in GetGroups("LDAP://"+$sGroup,$sIndent+Left($sIndent,1))
If Not(ASCan($GetGroups,$sChain)+1) OR $sIndent
$GetGroups=Split(Join($GetGroups,Chr(10))+Chr(10)+$sChain,Chr(10))
EndIf
Next
Next
$GetGroups=Split(SubStr(Join($GetGroups,Chr(10)),2),Chr(10))
EndFunction


; Sub-Function for returning nested groups
Function GetNested($objGroup)
Dim $_colMembers, $_strMember, $_strPath, $_objNestedGroup, $_ERR
; init the return value to a null string
$GetNested = ''
; get the collection
$_colMembers = $objGroup.GetEx("memberOf")
; enumerate the collection
For Each $_strMember in $_colMembers
$_strPath = "LDAP://" + $_strMember
$_objNestedGroup = GetObject($_strPath)
$GetNested = $_objNestedGroup.CN
Next
Exit 0
EndFunction




If I use this code, doesn't work, InGroup don't see nested groups.



C:\Windows\SYSVOL\sysvol\cmnet.cloud\scripts>kix32 grouptest.src

User is a member of the following:
CN=MAPFAITEC,OU=Faitec,OU=USUARIOS,OU=ACCOR,DC=cmnet,DC=cloud
>CN=GG_BRSP03017A_EMPRESAS_08BELASARTES_MODIFY,OU=008-HB289-BELAS ARTES,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>CN=GG_BRSP03017A_EMPRESAS_08BELASARTES_READ,OU=008-HB289-BELAS ARTES,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>>CN=DL_BRSP03017A_EMPRESAS_08BELASARTES_READ,OU=008-HB289-BELAS ARTES,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>>CN=GG_BRSP03017A_EMPRESA_MAP_DRIVE,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>>>CN=Citrix Fileshare ArquivosCMNet,OU=CITRIX,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>>>CN=DL_BRSP03017A_EMPRESA_LIST,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
>>CN=DL_BRSP03017A_EMPRESAS_08BELASARTES_MODIFY,OU=008-HB289-BELAS ARTES,OU=EMPRESAS,OU=BRSP03017A,OU=GRUPOS,OU=ACCOR,DC=cmnet,DC=cloud
CN=Domain Admins,CN=Users,DC=cmnet,DC=cloud
>CN=SophosAdministrator,CN=Users,DC=cmnet,DC=cloud
>CN=Denied RODC Password Replication Group,CN=Users,DC=cmnet,DC=cloud
>CN=Administrators,CN=Builtin,DC=cmnet,DC=cloud




not a member
 Quote:
 Quote: