Solved

Type mismatch on Join

Posted on 2003-10-26
7
741 Views
Last Modified: 2008-02-23
I have created a script to map a drive based on group membership. Here is a listing of the applicable lines in the script:

====================================================
' Create required objects
Set wshNetwork = CreateObject("WScript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")
Set wshShell = WScript.CreateObject("WScript.Shell")
set objFSO = createobject("Scripting.FileSystemObject")

' Get users' username
Set CurrentUser = GetObject("LDAP://" & objSysInfo.UserName)

' Get user's group list
strGroups = LCase(Join(CurrentUser.MemberOf))

' Map network drives
If InStr(strGroups, "cn=Corporate") Then
      wshNetwork.MapNetworkDrive "Q:", "\\BNESRV1\CORPORATE"
End If
====================================================

When a user run the script the following error is displayed:

\\bnesrv1\netlogon\logon.vbs(11, 1) Microsoft VBScript runtime error: Type mismatch: 'Join'

The script runs OK as a Domain Admin and I have also tested the script with the user being an administrator on the local machine.

Any ideas?
Thanks in advance.


0
Comment
Question by:aaronp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 150 total points
ID: 9625536
Try check whether your value pass in is an array or not.

Example:

..
If IsArray(CurrentUser.MemberOf) Then
   strGroups = LCase(Join(CurrentUser.MemberOf))
Else
   strGroups = LCase(CurrentUser.MemberOf)
End if
..
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9626583
This shud solve:

dim grp

' Get user's group list

strGroups = ""
for each grp in CurrentUser.MemberOf
   strGroups = strGroups & " " & LCase(grp)
next grp


use this, instead of the join thing.

Generally, something like this member of property, wud return a collection or an object collection etc.
Join works for arrays only.
0
 

Author Comment

by:aaronp
ID: 9631005
Thanks for the replies.

I tried this one:

If IsArray(CurrentUser.MemberOf) Then
   strGroups = LCase(Join(CurrentUser.MemberOf))
Else
   strGroups = LCase(CurrentUser.MemberOf)
End if

And it runs the join for a domain admin, but the Else statement for a user. Now that's get me stumped.

This one give me 'object not a collection'

for each grp in CurrentUser.MemberOf
   strGroups = strGroups & " " & LCase(grp)
next grp


0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 52

Expert Comment

by:Ryan Chong
ID: 9632948
First, we need to know what is returned from CurrentUser.MemberOf, seems that it's not a collection, which is not allow in the for each statement.

and what's the data type of CurrentUser, how you declare this variable?
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9639237
run the :

If IsArray(CurrentUser.MemberOf) Then
   strGroups = LCase(Join(CurrentUser.MemberOf))    '<----set a breakpt here
Else
   strGroups = LCase(CurrentUser.MemberOf)    '<----set a breakpt here
End if

set a break point at thsoe 2 places and add the "currentuser.memberof " to the watch.
This will display the object structure. Based on that u can decide how to join the grps.
0
 
LVL 7

Accepted Solution

by:
_agj_ earned 150 total points
ID: 9639252
U could also do this stuff in anotehr way.

as in, what u want is to check if a user is in grp "Corporate" and if so, map the network drive.

There is some method to check directly if a user is a group, given the user and grp name.

>>"And it runs the join for a domain admin, but the Else statement for a user. Now that's get me stumped."

This could be coz the admin is a memeber of multiple grp and the user has only one grp.
0
 

Author Comment

by:aaronp
ID: 9639437
Ah.. the script does not return the group 'Domain Users', thanks _agj_ thats the reason why the join does not work. Thanks as well to ryancys.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question