Link to home
Start Free TrialLog in
Avatar of Ducknaldi
Ducknaldi

asked on

login script, map url attribute of membership group with 20 in it´s name:)

Is it doable or too complicated to create a login script which map the url attribute of a membership group with 20 in it´s name.
I´m tinking, something like first enumerating groups for the user, then picking the group from this list with 20 in it´s name, then grabbing the url attribute (objUser.Get("url")) of the group and mapping it as a driver letter.
Avatar of Tasmant
Tasmant
Flag of France image

I think it's a bit more complicated what you want to achieve.
You should explain us better what is your need, how you provide information to map drives for users ...
there's a lot of way to map drivers for users, and this can be achieved with security groups (ie one map per group)

But ... to answer to your question, you can do exactly what you want with this:
You can put this code in a logon script batch file. If you set it in a script, you need to use %% syntax.


for /f "tokens=*" %%i in ('dsquery user -name %username% ^| dsget user -memberof ^| find "20"') do for /f "tokens=* skip=1" %%j in ('dsquery * %%i -attr url') do net use z: %%j

Open in new window

for /f "tokens=*" %i in ('dsquery user -name %username% ^| dsget user -memberof ^| find "20"') do for /f "tokens=* skip=1" %j in ('dsquery * %i -attr url') do net use z: %j

Open in new window

Avatar of Ducknaldi
Ducknaldi

ASKER

Hi Tasmant

I have a lot of students in my AD, these students are members of several groups.
One of these groups is their class group and this group has the url attribute set for there class home drive.
Insted of having a policy for each class mapping this drive, I want one script to do it for all students.
The group names with the url attribute set, are all named after the year the students started on the school, like val_2000A, tin_2003B, rod_2010C etc..
Other groups are not named in the same fashion, which is why I´d like to distingiush on the number 20, since it would apply for all the relevant groups and noone else.
I do not have access to test it before monday, but it looks like you understand what I want to achieve and I think this might be it.
Oh and by the way, class folders and the url attribute is already in place due to the existing structure, which is why I want to use it for mapping class drives also, so I can get rid of all our time demanding class home drive mapping policies.
if they are members of several groups but only one with "20" in the name, my script works.
if you want another (maybe vbs), sure we could, just need a bit more time :)
I would prefer vbs, in case the script needs extra functions some day or need to be combined with existing scripts.
I haven´t tested your cmd line yet, cause today seems to be dhcp problems day:)
I´d have to copy dsquery to the clients for this cmd line to work, or?
yes, or launch it within their logonscript.
if you use direct command, take the one % syntax command
if you use logon script (.bat file), take the double %% syntax command
i'll try to post the vbs soon
ASKER CERTIFIED SOLUTION
Avatar of Tasmant
Tasmant
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It worked perfectly with no corrections at all.
Furthermore, I see many other uses for this script.
Thank you alot.
I just got rid of hundreds of policies thanks to you;)