0
當運行下面的VBS函數來檢查當前用戶是否在某個安全組中時,對於行strGroup = LCase(Join(CurrentUser.MemberOf))
,我得到錯誤#500(變量未定義)。當定義了某個變量時,VBS函數總是返回False
我有Option Explicit
在腳本中聲明,所以這並不奇怪。但是,當我聲明變量(Dim strGroup
)時,該函數停止工作並始終返回false。
Function is_group_member(group)
Dim objNetwork
Dim objUser
Dim CurrentUser
' Set our default return value
is_group_member = False
' Directory Lookup
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(CurrentUser.MemberOf))
' Set return value to true if the user is in the selected group
If InStr(strGroup, lcase(group)) Then
is_group_member = True
End If
End Function
感謝您的回覆,我會看看。看起來您的調試器鏈接不正確,因爲無法找到頁面。謝謝。 –
感謝您對下載鏈接的反饋,我已經解決了它。 –
謝謝。參加幾次會議,今天晚些時候會抓住它。 –