Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

InStr Always Returns 0....

66 views
Skip to first unread message

Rob

unread,
Apr 7, 2006, 2:33:31 PM4/7/06
to
I've been beating on this script for the past day and am getting some
very odd results. I'm pulling a users' group associations from AD and
matching it to a known group so I can map drives accordingly. I am
pulling the group names easily enough but I can't seem to get a match.
I am printing out the value of the groups string and the group match
string but I always get a 0 from InStr. Can someone tell me what I'm
doing wrong here?

When debugging the print out of strGroup is always
"cn=owners,cn=users,dn=domain,dn=com"
and OWNERS_GROUP is always "cn=users"

I can't figure out why I can't match OWNERS_GROUP to part of the string
in strGroups...

TIA


Dim objNetwork, objUser, CurrentUser, strGroup, GroupList, colGroups
Dim OWNERS_GROUP, STAFF_GROUP

OWNERS_GROUP = "cn=owners"
STAFF_GROUP = "cn=staff"

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

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

'WScript.Echo " Groups: "& strGroups
'WScript.Echo " Groups Str: "& OWNERS_GROUP
'GroupList = "" & CurrentUser.MemberOf
'Response.Write GroupList
'strGroups = LCase(Join(GroupList))

pos=InStrRev(strGroup, OWNERS_GROUP)
WScript.Echo " Pos: "& pos

' Extra code just to add a message box
'WScript.Echo " Launch Explorer, check: "& strDriveLetter

If InStrRev(strGroup, STAFF_GROUP) Then
wshNetwork.MapNetworkDrive "s:", "\\server\public"

ElseIf InStrRev(strGroup, OWNERS_GROUP) Then
wshNetwork.MapNetworkDrive "o:", "\\server\private"
wshNetwork.MapNetworkDrive "s:", "\\server\public"

End If

John Connor

unread,
Apr 11, 2006, 11:24:09 AM4/11/06
to
Just at a quick glance, in your InStr you are using strGroup, but the
variable above it is strGroups with an 's'. Not sure if this is the
issue but just something i noticed.

0 new messages