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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

currentUser.memberOf, login script error 2

Status
Not open for further replies.

jigga8517

Technical User
Mar 5, 2003
2
US
I am new to scripting and this forum, bear with me please. I am creating a login script for windows 2000 server.

--------
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)

'Next line gives me error
strGroups = LCase(Join(CurrentUser.MemberOf))
--------

Here's what I know:
- Join gives me type mismatch error when the user is a member of Domain user and only one other group.

- Join works when the user is a member of domain user and more than one other group.

Here's what I think: MemberOf attribute is returning a string when the member is part of only 1 group other than domain user. MemberOf attribute is returning an array when the member is part of more than 1 group other than domain user.

WHY????????? - Why does this attribute behave this way, and what can I do about it.

 
Welcome to ADSI. Your suspicions are correct, the MemberOf property (and Member property if it's a group) will return different datatypes, depending on the value. You'll need to first check the variable's subtype.

Sub WhatKindOfUser(oUser)
Select Case VarType(oUser.MemberOf)
Case 0
MsgBox "Member is in no groups"
Case 8
MsgBox "Member is in one group"
Case 8204
MsgBox "Member is in more than one group"
End Select
End Sub

You'll only be able to utilize the Join function when the Vartype function returns 8204, ie, an array of strings.

Also, see Jon Hawkins
 
Thanks a lot Jon. I knew something was up, however I couldn't find any solid documentation.

Thanks again,
Jigar P.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top