0
我有一個腳本來映射基於AD組的打印機。我發現它不適用於某些用戶,經過一番挖掘,我意識到它與組名或OU的斜線有關。如何處理AD OU和組名稱上的斜槓?
我的問題是,我怎樣才能改善我的腳本來處理這個問題而不必改變它整個?
這裏是處理用戶的身份,並列出組的部分:
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
任何幫助將不勝感激!
Regards
* ...它與組名或OU上的斜槓相關* ...如何?你有錯誤嗎?它說什麼?您發佈的代碼是導致問題的部分嗎?有問題的值是什麼樣的? –
它應該在兩種情況下都失敗。我確實收到以下錯誤:「(null):0x80005000,指的是 –
'strUserPath'的值是什麼樣子的。 strUserPath =「LDAP://」&Replace(objSysInfo.UserName,「/」,「\ /」)'? –