我有一个HTA文件,它只是挂在我从LDAP查询循环组条目的过程中。
/j:link
是否有更有效的方法来迭代这些组,80 +是一系列的组循环并导致问题。
或者我可能尝试将整个列表转储到字符串并对其进行Set objUser = GetObject("LDAP://" & strUserDN)
For Each objGroup In objUser.Groups
If "wifi user" = lcase(replace(objGroup.Name,"CN=","")) Then
'modify my dom element here....
End If
If "encryption enabled" = lcase(replace(objGroup.Name,"CN=","")) Then
'modify my dom element here....
End If
If "dl - some office" = lcase(replace(objGroup.Name,"CN=","")) Then
'modify my dom element here....
End If
Next
查询?
答案 0 :(得分:0)
下面的代码更改有一个显着的改进,其中只循环一个命名列表与整个单个组对象。我的PowerShell逻辑启动并让我和@Ansgar Wiechers一起进行了更深入的测试。谢谢!
Set objUser = GetObject("LDAP://" & strUserDN)
arrGroup = objUser.MemberOf
strGroup = ""
For i = 0 To UBound(arrGroup)
strGroup = arrGroup(i)
If InStr(lcase(strGroup),"vpn user") Then
WScript.echo "block grp 1"
End If
If InStr(lcase(strGroup),"dl - some office") Then
WScript.echo "block grp 2"
End If
If InStr(lcase(strGroup),"encryption enabled") Then
WScript.echo "block grp 3"
End If
If InStr(LCase(strGroup), "wireless") Then
strWifi = True
End If
Next