Script not working correctly for users w/out admin rights to the server

Script not working correctly for users w/out admin rights to the server

Post by SmVycn » Mon, 14 Jun 2004 00:46:02


I have a small network running Server 2003. I have created a logon script based on the example I obtained from Help & Support. It looks something like this:

Const SOME_GROUP = "cn=somegroup"

Set wshNetwork = CreateObject("WScript.Network")

wshNetwork.MapNetworkDrive "u:", "\\Server\SomeFolder" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "m:", "\\Server\SomeFolder"

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, SOME_GROUP) Then

wshNetwork.MapNetworkDrive "Q:", "\\Server\SomeFolder"

End If

My problem is that my users that do not have admin rights to the server get an type mismatch error for the "Join" setting in line 10. I don't want to give all my users admin rights to the server but so far that is the only way I have found to fix the problem. Can someone please provide a better way?
 
 
 

Script not working correctly for users w/out admin rights to the server

Post by Richard Mu » Mon, 14 Jun 2004 01:43:07


based on the example I obtained from Help & Support. It looks something like
this:
wshNetwork.UserName
get an type mismatch error for the "Join" setting in line 10. I don't want
to give all my users admin rights to the server but so far that is the only
way I have found to fix the problem. Can someone please provide a better
way?

Hi,

Every user should have rights to read the memberOf attribute of their user
object, unless this permission has been specifically denied. A more likely
explanation is that the code you posted will fail if CurrentUser.memberOf is
not an array. The code should account for the memberOf attribute having many
values, one value, or no values. A "type mismatch" error is raised if
memberOf has one or no values in the collection. I use code similar to:

colGroups = objCurrentUser.memberOf
If IsEmpty(colGroups) Then
strGroups = ""
ElseIf TypeName(colGroups) = "String" Then
strGroups = LCase(colGroups)
Else
strGroups = LCase(Join(colGroups))
End If

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.yqcomputer.com/