LDAP 组对象循环
LDAP Group object loop
我有一个 HTA 文件,它只是在我循环访问来自 LDAP 查询的组条目的过程中挂起。
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
是否有更有效的方法来遍历这些组,80+ 是一组循环并导致问题的组。
或者我可能会尝试将整个列表转储为一个字符串并对其进行 InStr
查询?
下面的代码更改有了显着的改进,其中循环只遍历一个命名列表而不是整个单个组对象。我的 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
我有一个 HTA 文件,它只是在我循环访问来自 LDAP 查询的组条目的过程中挂起。
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
是否有更有效的方法来遍历这些组,80+ 是一组循环并导致问题的组。
或者我可能会尝试将整个列表转储为一个字符串并对其进行 InStr
查询?
下面的代码更改有了显着的改进,其中循环只遍历一个命名列表而不是整个单个组对象。我的 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