LDAP组对象循环



我有一个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

相关内容

  • 没有找到相关文章

最新更新