Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript problem: type mismatch error, on windows 2000

Status
Not open for further replies.

kitokato

Technical User
Aug 31, 2004
5
FI
Hello,
Im quite sad on scripting so please keep that in mind while answering :)

My problem is that the script below gives a error (while running on windows 2000) :
line : 13
char : 1
error: Type mismatch : 'Join'
code : 800A000D
Source Microsoft VBScript runtime error


- it works fine in windows XP
- basically what im trying to do is to have a network drive mapped if logged on user belongs to group sharex_grp in Active Directory

Any help will be appriciated.
(please say if more information is needed about the envirnment...)

script is as follows:

Option Explicit
Dim strGroups
Dim wshNetwork
Dim CurrentUser
Dim ADSysInfo

Const sharex_grp = "cn=sharex_grp"

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

If InStr(strGroups, sharex_grp) Then
'Map network drive
wshNetwork.MapNetworkDrive "Y:", "\\111.222.333.444\share\"
else
msgbox "you are not in the sharex group"
end if

Set strGroups = Nothing
Set wshNetwork = Nothing
Set CurrentUser = Nothing
Set ADSysInfo = Nothing
WScript.Quit
 
The Join() function takes an array an an optional delmitter.

What happens if you add a conditional statement to test the array before you call Join() ???

Something like this:
If Not IsArray(CurrentUser.MemberOf) Then
MsgBox "CurrentUser.MemberOf is not an array!"
End If

 
kitokato,
Do this instead.
[tt] strGroups = LCase(Join(CurrentUser.[red]getex("MemberOf")[/red]))[/tt]
In case you want to delimit better, do like this.
[tt] strGroups = LCase(Join(CurrentUser.[red]getex("MemberOf"),","[/red])[/tt]
for comma delimitation.
regards - tsuji

 
Thank you all very much for quick replys
and tsuji for the excellent script.
It seemed to do the trick.

(btw. it appears that you are missing a " ) " :
strGroups = LCase(Join(CurrentUser.getex("MemberOf"),","))
 
It happens all the times to me, kitokato!
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top