Re: login problem
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Oct 2007 10:39:35 -0500
One group other than "Domain Users" is not enough to prevent the error. The
"For Each" statement expects a "Variant()", which is an array or collection.
If objUser.memberOf is Empty, it is not an array and an error is raised. If
objUser.memberOf has one group Distinguished Name, it is "String" and again
an "object is not a collection" error is raised. The only time "For Each
strGroup In objUser.memberOf" does not raise an error is when the user is
the direct member of at least two groups, not counting the "primary" group
of the user.
The best way to troubleshoot the script is to run it after logon at a
command prompt without "On Error Resume Next" so you can see error messages.
The error message includes the line number, so you can use the Edit command
(which shows line numbers) to find which statement raised the error. You
need to test with users that have no memberships (other than "Domain
Users"), users with one membership, and users with two or more direct
memberships (not membership due to group nesting).
This is a common problem because the Microsoft example is flawed. You can
often "hide" the problem by using "On Error Resume Next", but then all
errors are ignored. Even a simple typo becomes impossible to troubleshoot.
Often a script is flawed and no one even knows for a long time. Logon
scripts are important. If anything goes wrong you want to know, not hide the
problem.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"leopete" <leopete@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3E26FD10-847D-4C8D-95D0-76C5F64B6B9C@xxxxxxxxxxxxxxxx
I tried what you suggested and still no luck. Each of our users
belong
to one group other than domain users. When is used the old script i was
getting "object is not a collection".
--
The only easy day was Yesterday
"Richard Mueller [MVP]" wrote:
leopete wrote:
I enabled the following script,which i got from microsoft, for user
login
though active directory.
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
Select Case strGroupName
Case "Finance Users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\finance"
Case "Human Resource Users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\hr"
Case "Manufacturing Users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\manufacturing"
Case "Shipping and Receiving Users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\shipping"
End Select
Next
I changed the script paths to fit our environment. When i have users
login
to their computer nothing happens. I know theirs issues with the
"memberOf
attribute"
but everything that i did to changed it didnt work.
Please Help
I would suggest not using "On Error Resume Next" so you see error
messages.
Next, it might help to use LCase or UCase to make the comparisons case
insensitive. The statement:
For Each strGroup In objUser.memberOf
will raise an error unless the user is a direct member of at least two
groups, not counting the "primary" group (usually "Domain Users"). I
would
suggest:
================
Option Explicit
Dim objSysInfo, objNetwork, strUserPath
Dim objUser, arrGroups, strGroup
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
arrGroups = objUser.MemberOf
If IsEmpty(arrGroups) Then
Wscript.Quit
ElseIf (TypeName(arrGroups) = "String") Then
Call ChkGroup(arrGroups)
Else
For Each strGroup In arrGroups
Call ChkGroup(strGroup)
Next
End If
Sub ChkGroup(ByVal strGroup)
Dim objGroup
Set objGroup = GetObject("LDAP://" & strGroup)
Select Case LCase(objGroup.cn)
Case "finance users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\finance"
Case "human resource users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\hr"
Case "manufacturing users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\manufacturing"
Case "shipping and receiving users"
objNetwork.MapNetworkDrive "X:", "\\atl-fs-01\shipping"
End Select
End Sub
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: login problem
- From: leopete
- Re: login problem
- References:
- login problem
- From: leopete
- Re: login problem
- From: Richard Mueller [MVP]
- Re: login problem
- From: leopete
- login problem
- Prev by Date: Re: List users connected via Remote Desktop & console?
- Next by Date: Re: List users connected via Remote Desktop & console?
- Previous by thread: Re: login problem
- Next by thread: Re: login problem
- Index(es):
Relevant Pages
|
Loading