Hey guys,

I have been constantly working and reworking my logon script for my
enterprise network here and I am always looking for better ways of
doing things.

Currently drives are mapped and files copied using security groups and
thats where it gets tricky. How do you cycle through all the groups the
user is in without slowing down the script?

So I was wondering what you guys do? Could you post a snipet of your
logon script code?

Currently I make an string of the groups the user is in by doing this:

For Each GroupObj In UserObj.Groups
UserGroups=UserGroups & "[" & UCASE(GroupObj.Name) & "]"
Next

Then I have a case statment with lots of these:

If InGroup("Stuff") Then
mapdrive "U:", "\\server\share"
End If

And that uses this function:

Function InGroup(strGroup)
InGroup=False
If InStr(UserGroups,"[" & strGroup & "]") Then
InGroup=True
End If
End Function

Problem is... the list of groups is getting pretty big and each user
needs to step through each case statment. And I am thinking it would be
more efficient if it would only run the parts that were required?

So back to my question. Does anyone have some cool code I can nab off
them?

Thanks,
Euan

Re: Show me your... Logon Script by Roland

Roland
Mon Nov 07 10:50:46 CST 2005

"Euan" <euan@madprops.org> wrote in message
news:1131338950.284719.252990@g47g2000cwa.googlegroups.com...
: Hey guys,
:
: I have been constantly working and reworking my logon script for my
: enterprise network here and I am always looking for better ways of
: doing things.
:
: Currently drives are mapped and files copied using security groups and
: thats where it gets tricky. How do you cycle through all the groups the
: user is in without slowing down the script?
:
: So I was wondering what you guys do? Could you post a snipet of your
: logon script code?
:
: Currently I make an string of the groups the user is in by doing this:
:
: For Each GroupObj In UserObj.Groups
: UserGroups=UserGroups & "[" & UCASE(GroupObj.Name) & "]"
: Next
:
: Then I have a case statment with lots of these:
:
: If InGroup("Stuff") Then
: mapdrive "U:", "\\server\share"
: End If
:
: And that uses this function:
:
: Function InGroup(strGroup)
: InGroup=False
: If InStr(UserGroups,"[" & strGroup & "]") Then
: InGroup=True
: End If
: End Function
:
: Problem is... the list of groups is getting pretty big and each user
: needs to step through each case statment. And I am thinking it would be
: more efficient if it would only run the parts that were required?

If you have certain groups that everyone is part of, you don't have to test
for those. If you have certain groups where departments may be in numerous
groups, then knowing the department can be a single test to assign multiple
groups.

You don't need two conditionals here:

If InGroup("Stuff") Then
mapdrive "U:", "\\server\share"
End If

Function InGroup(strGroup)
InGroup=False
If InStr(UserGroups,"[" & strGroup & "]") Then
InGroup=True
End If
End Function

And you should take advantage of your loop, which you don't appear to be
doing...

For Each GroupObj In UserObj.Groups
UserGroups=UserGroups & "[" & UCASE(GroupObj.Name) & "]"
Next

Something like this might work faster...

for each groupObj in userObj.Groups
select case groupObj.Name
case "Stuff"
mapdrive "u:", "\server\share"
case "MoreStuff"
mapdrive "v:", "\server\share"
case else
end select
next

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Show me your... Logon Script by Euan

Euan
Mon Nov 07 14:58:59 CST 2005

Yeah I didnt look at it that way. Thanks for your help. I will rework
the script now and see how it goes.

Regards,
Euan