Re: Log on script error
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Nov 2006 11:10:41 -0600
There should be no reason to specify a particular DC in the binding string,
unless you are retrieving the value of an attribute that is not replicated
(has a different value on each DC). It should be safer to not specify a DC.
However, I cannot explain why it works for some users and not others.
I should also point out that the next line in your script will raise an
error if the user is not a member of at least two groups (not counting the
"primary" group, usually "Domain Users"). When dealing with multi-valued
attributes like memberOf, make sure the script works in all 3 possible
cases: no values, one value, more than one. I would suggest:
=============
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
arrGroups = CurrentUser.memberOf
If (IsEmpty(arrGroups) = True) Then
strGroups = ""
ElseIf (TypeName(arrGroups) = "String") Then
strGroups = LCase(arrGroups)
Else
strGroups = LCase(Join(arrGroups)
End If
============
Even after this I dislike the method. I'm sure most people check group
membership with InStr to check if the NetBIOS name of the group is in the
string. This can give erroneous results, unless you check for the full
Distinguished Name of the group. Depending on your purpose, there are other
ways to check group membership. For example, you might be able to use the
IsMember method of the group object. You pass the AdsPath of the user to
this method and it returns True if the user is a member. An example logon
script that uses this method to check group membership is linked here:
http://www.rlmueller.net/Logon4.htm
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
<glasseigne@xxxxxxxxxxxxxx> wrote in message
news:1163435809.791979.224250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I error using the following script:
---start snippet
Dim objNetwork
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://<AD server name replaced>/" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
---end snippet
The line that errors is the Set CurrentUser. It does not happen with
every user, just a few. I cannot figure out what's common with the
users it errors on.
Thanks
.
- Follow-Ups:
- Re: Log on script error
- From: glasseigne
- Re: Log on script error
- References:
- Log on script error
- From: glasseigne
- Log on script error
- Prev by Date: Log on script error
- Next by Date: Re: Log on script error
- Previous by thread: Log on script error
- Next by thread: Re: Log on script error
- Index(es):
Relevant Pages
|