Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Scripts If you need or have any scripts then get 'em here.

Go Back   EduGeek.net Forums > Coding and Web Development > Scripts
Reply
 
LinkBack Thread Tools Search Thread
Sponsored Links
Old 20-06-2009, 12:07 PM   #1
 
Ignatius's Avatar
 
Join Date: May 2009
Location: UK
Posts: 151
uk uk yorkshire
Thanks: 27
Thanked 14 Times in 13 Posts
Rep Power: 4 Ignatius will become famous soon enough
Default Map folder depending upon group membership in workgroup

This is easy in a domain, but my scenario is a workgroup of XP Pro PCs. One is designated as a File Server and I need to be able to map to a particular folder, depending upon the group to which the user belongs. I have a startup script in the C:\...\All Users\Start Menu\Programs\Startup of each PC and would like to add to it. I know I can have:

Code:
net use * /delete
net use f: \\server\AdminShare
or
Code:
net use * /delete
net use g: \\server\OtherShare
etc. in each specific users' Startup folder but I'd like to have it run from the All Users' Startup folder so I don't have to put the login script into the specific folder when I create new users and allocate them to groups.

Is there any way to do this? I thought of this pseudocode:
Code:
net use * /delete
if group = "Administrators" then
     net use f: \\server\AdminShare
goto end
if group = "Power Users" then
    net use f: \\server\OtherShare
goto end
Maybe someone can suggest a simpler solution for me? I know that the syntax that I've given isn't VBS but I'd hope to incorporate any suggestions into my VBS login script.

Thanks in advance.
  Reply With Quote
Old 20-06-2009, 01:15 PM   #2
 
Michael's Avatar
 
Join Date: Dec 2005
Location: Birmingham
Posts: 4,820
uk uk england
Thanks: 85
Thanked 681 Times in 519 Posts
Rep Power: 137 Michael ooh
Michael ooh Michael ooh Michael ooh Michael ooh Michael ooh Michael ooh
Default

There isn't really any simple solution to this. You could map both drives in a single logon script, but then configure permissions so users can access either one or the other (depending who they logon as).
  Reply With Quote
Old 20-06-2009, 02:12 PM   #3
 
Ignatius's Avatar
 
Join Date: May 2009
Location: UK
Posts: 151
uk uk yorkshire
Thanks: 27
Thanked 14 Times in 13 Posts
Rep Power: 4 Ignatius will become famous soon enough
Default

Thanks Michael. I've configured the share and folder permissions appropriately. I'd prefer to hide folders to which users don't have access, hence the idea of deleting all the mapped folders and recreating the mapping at each login.

Since posting earlier today, I've investigated further:

Code:
net localgroup > group.txt
will get me a list of local groups. I can run through them:

Code:
net localgroup <groupname> | find "Name" (I need to check the syntax of passing %username% to this line)
but I'll need to save the groupname to a variable if "Name" is found in this group.

I *think* I'm on the right track but realise that it's not so easy as it would be if it were a domain.
  Reply With Quote
Old 20-06-2009, 03:05 PM   #4
 
Michael's Avatar
 
Join Date: Dec 2005
Location: Birmingham
Posts: 4,820
uk uk england
Thanks: 85
Thanked 681 Times in 519 Posts
Rep Power: 137 Michael ooh
Michael ooh Michael ooh Michael ooh Michael ooh Michael ooh Michael ooh
Default

This article may point you in the right direction.
  Reply With Quote
Thanks to Michael from:
Ignatius (20-06-2009)
Old 20-06-2009, 03:41 PM   #5
 
Ignatius's Avatar
 
Join Date: May 2009
Location: UK
Posts: 151
uk uk yorkshire
Thanks: 27
Thanked 14 Times in 13 Posts
Rep Power: 4 Ignatius will become famous soon enough
Default

Thanks again. I'd had a look at that site and suspect that the code relates to a domain rather than a workgroup. When it mentions "groups", I think it refers to AD groups.

I'll be able to test this out early next week on the workgroup and I'll also have access to a Windows 2003 and single XP Pro client to check out whether it's only for a domain.
  Reply With Quote
Old 21-06-2009, 10:06 AM   #6
 
srochford's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 2,259
uk
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1
Rep Power: 72 srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future
Default

You should be able to use the code below. Basically, it gets the name of the user and computer, clears all existing drive mappings and then connects to the user object to get its properties. It then loops through all the groups, converts the name to lower case (may not be necessary but does no harm ...) and then calls a routine to check what drives should be mapped for the groups.

You'll need to change the "mapdrive" subroutine to deal with the groups you have and the shares you want to use.

the only thing this won't cope with is nested groups but I'm guessing that in a workgroup you're not likely to have such a problem.

Code:
Set oNetwork = CreateObject("Wscript.Network")
sUser=oNetwork.UserName
sComputer=oNetwork.computername

ClearMappedDrives

set oUser=getobject("WinNT://" & sComputer & "/" & sUser)


for each oGroup in oUser.groups
  sGroup=lcase(oGroup.name)
  MapDrive sGroup
next


sub clearmappeddrives
  set oDrives=oNetwork.enumnetworkdrives
  For i = 0 to oDrives.Count - 1 Step 2
    onetwork.removenetworkdrive oDrives.Item(i)
  Next
end sub

sub MapDrive(sGroup)
  select case sGroup
    case "administrators"
      oNetwork.mapnetworkdrive "z:","\\computer1\share1"
      oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs"
    case "finance"
     oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs"
    case "registry"
     oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs"
  end select
end sub
  Reply With Quote
Thanks to srochford from:
Ignatius (21-06-2009)
Old 21-06-2009, 11:17 AM   #7
 
Ignatius's Avatar
 
Join Date: May 2009
Location: UK
Posts: 151
uk uk yorkshire
Thanks: 27
Thanked 14 Times in 13 Posts
Rep Power: 4 Ignatius will become famous soon enough
Default

Thanks Steve - that looks good. I'll be able to test it within the next few days.
  Reply With Quote
Reply

EduGeek.net Forums > Coding and Web Development > Scripts

Similar Threads
Thread Thread Starter Forum Replies Last Post
[ASP.net] Show webpage based on group membership MK-2 Web Development 1 09-04-2009 11:53 AM
Group Policy loopback affecting folder redirection rocknrollstar Windows 2 25-11-2008 08:05 AM
Changing AD home folder location to a group? mrbios Windows 2 01-08-2007 10:59 AM
Group Policy folder lockdown speckytecky General Chat 2 12-07-2007 08:29 AM
Group Membership Woes (Need Help) ICTNUT Windows 11 02-12-2005 04:19 PM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:02 PM.
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright EduGeek.net




website uptime

© 2005 - 2009 EduGeek.net
SERVER: 4
no new posts