backbiter
(Lurker)
2006-08-22 07:17 AM
Map drive by user id.

I have a number of users that need to have a drive mapped to certain folders with in a folder. Each folder is unique to them as they contain information on their students classes. My idea was to just map each one of these users to their respective folder which is what the powers that be want. This is not code but rather my idea of where I want to go with my script. Please pardon my lack of scripting knowledge. I am using 4.52Kix on Server 2003 AD with all XP clients.
If userid = jdoe
Map drive V to \\enterprise\MISD\Melis1\eclass\12
Now check for errors

Thanks for any help. This board has helped me a bunch with my short Kixtart career.


Gargoyle
(MM club member)
2006-08-22 07:59 AM
Re: Map drive by user id.

Using that logic you will have to do an IF for every student.

Much easier would be to set it to their home folder in AD, or to create a shortcut to it in their home folder.


Witto
(MM club member)
2006-08-22 08:52 AM
Re: Map drive by user id.

If it is just info for one user, why don't you use the user directory?

backbiter
(Lurker)
2006-08-22 03:35 PM
Re: Map drive by user id.

Thanks for the replies. I had thought about this and I should have been a bit more clear about the use of these drives. They contain the teachers gradebooks that are used by their gradebook program so that is why I will have to do a mapping for each teacher. I tried using this.
If @userid = jdoe
use v: "\\server\share\melis1\eclass\12"
EndIf
It will debug fine after you log in but will not map with normal login. Any ideas?
Thanks guys.


ShawnAdministrator
(KiX Supporter)
2006-08-22 03:43 PM
Re: Map drive by user id.

Try tracing-out the error on logon, example:

use v: "\\server\share\melis1\eclass\12"

?"ERROR " + @ERROR + " - " + @SERROR
?"Press any key..." GET$

-Shawn


Witto
(MM club member)
2006-08-22 06:20 PM
Re: Map drive by user id.

Still my question, if it is for their gradebook, only used by their gradebook program, and they just need one "shared" folder for just one user, nobody else needs to consult it, why don't you use the users directory?
Or do you want to use something like
Code:
\\FileServer\GradebookShare\TeachersName


If possible, just let the program write to \\FileServer\GradebookShare\%UserName%
Set (Read?) security for all teachers in one group on \\FileServer\GradebookShare\
and (Modify?) security per teacher on \\FileServer\GradebookShare\%UserName%

If in your example the teacher jdoe was teacher number 12, could you name the deepshare '\\server\share\melis1\eclass\' + @USERID
In last case, you still have to debug like Shawn suggests.


backbiter
(Lurker)
2006-09-02 07:08 AM
Re: Map drive by user id.

Sorry for the delay in getting back on this. What I had to do was to actually map each teacher to their folder(s). Did it like this. It did take more keystrokes than I would like but it worked. The way this program creates the databases for the gradebook dictated the way I had to do mappings for each teacher that uses it. We can't change the folder numbers so we had to just map to them which bombed out the idea of home drives. Thanks for the error code help. After a couple of debug passes I got the coding correct and it started working great.
Code:

If @userid = bdunn

Use L: "\\enterprise\WinSchl\Melissa Middle School\Melis101\eclass\18"
?"ERROR " + @ERROR + " - " + @SERROR
EndIf



Witto
(MM club member)
2006-09-02 07:47 AM
Re: Map drive by user id.

An error message telling everything is OK is not really an error message, is it? IIWY I would drop that line.
Shawn suggested that line for tracing errors
Code:

Use L: /DEL
If @userid = "bdunn"
Use L: "\\enterprise\WinSchl\Melissa Middle School\Melis101\eclass\18"
EndIf



Les
(KiX Master)
2006-09-02 02:04 PM
Re: Map drive by user id.

How many of these IF conditions are you processing? More than one and you should be using SELECT CASE constructs. If more than a dozen, then a total rethink is needed.

Witto
(MM club member)
2006-09-02 08:24 PM
Re: Map drive by user id.

Totally agree with Les, select would be better.
Code:

Use L: /DEL
Select
Case @USERID = "bdunn"
Use L: "\\enterprise\WinSchl\Melissa Middle School\Melis101\eclass\18"
Case @USERID = "SomeoneElse"
Use L: "\\enterprise\WinSchl\Melissa Middle School\Melis101\eclass\OtherNumberIPresume"
EndSelect


I would review the installation of the program itself. Does it support UNC paths? If I understand well, the userdata is being written to L:.
I would like p.e. that the userdata could be written to a path like
"\\enterprise\WinSchl\Melissa Middle School\Melis101\eclass\%USERNAME%".
No need to do tricks during logon.
IMHO, even a subdirectory in the userdirectory would be much better.


Sealeopard
(KiX Master)
2006-09-03 04:30 AM
Re: Map drive by user id.

Can't you make the users members of a group and then use the groups to do the mapping? I cannot imagine that each user would have a different folder to map to with no overlap between users. Don't think that a teacher is teaching only a single class.

Gargoyle
(MM club member)
2006-09-03 06:31 AM
Re: Map drive by user id.

If this is anything like the software that I have installed before it is even worst than the Jens,

Each teacher not only has their own folder within the directory structure, but the each of the classes they teach (like in high school they would have 5 classes) would have a seperate grade book within that folder.

Some of the company's that make educational software (grade books, attendance etc) have no concept of how to make anything network ready.

I remember many a program that "had" to be installed, and the program would not work unless "everyone" had full permissions to the install directory.


Sealeopard
(KiX Master)
2006-09-03 06:45 AM
Re: Map drive by user id.

Create groups named after each folder. Generate a list of folders a user belongs to and map according to that folder name. This way the code doesn't change and the mappings are controlled by assigning users to groups within Windows instead of within the script.

Glenn BarnasAdministrator
(KiX Supporter)
2006-09-17 02:57 AM
Re: Map drive by user id.

The KiX based login script on my web site supports this - called Path Rewriting.

You can define a resource record in the login config file, where
Code:
PATH=\\server\share\&USER:map_id&


This tells the drive mapping routine to use the user ID of the person logging in as a reference to a lookup record. The value returned by that record replaces the &USER:map_id& part of the path. That can be anything - the server, share, or deep-map directory name! Much easier to maintain the lookup records than multiple if/case statements, especially when user IDs change.

The login script can also do path rewriting based on AD Site IDs, as well as direct UserID and Site ID replacements, not to mention "normal" and even "complex" AD Group based mappings.

This type of functionality is helpful when you have a "team" of users to connect to a share that are not necessarily a specific AD group.

Navigate to the Products / Admin Toolchest section of my web site to locate the login script ZIP file.

Glenn


Sealeopard
(KiX Master)
2006-09-17 01:37 PM
Re: Map drive by user id.

The MapDrive() - Maps a UNC name to a specific driveletter UDF also supports "rewrting" in form of macros, e.g.
Code:

;non-persistent map of \\SERVER\share to P: with e.g. label "Jens Meyer's personal share"
$rc = MAPDRIVE('P','\\SERVER\@USERID$',0,"@FULLNAME's personal share")