我有一个脚本来根据AD组映射打印机。我发现它不适用于某些用户,经过一些挖掘后我发现它与组名或OU的斜杠有关。
我的问题是,如何在不必彻底改变的情况下改进我的脚本来处理它?</ p>
以下是处理用户身份并列出群组的部分:
on error resume next
'determines the user who just logged on
Set objSysInfo = CreateObject("ADSystemInfo")
Set WSHNetwork = CreateObject("WScript.Network")
'As soon as we tack on LDAP:// and construct an ADsPath we then bind to the user account in
'Active Directory and report back the groups the user belongs to; this can be done simply
'by enumerating the values in the MemberOf attribute.
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each objGroup in objUser.Groups
strGroupName = objGroup.CN
任何帮助将不胜感激!
此致
答案 0 :(得分:1)
尝试在用户名中转义斜杠。它们可能会在LDAP URL中被误解。
strUserPath = "LDAP://" & Replace(objSysInfo.UserName, "/", "\/")