[OpenAFS] mapping afs homedirs for windows users

Stephen Joyce stephen@physics.unc.edu
Fri, 21 Dec 2007 16:15:29 -0500 (EST)


Unlike Rodney, we don't refer to a unix passwd file, but build the paths. 
We create the smb mounts and map 4 static global drives via a startup 
script. We map 2 user drives (dynamic per user) via the logon script, which 
follows. (More advice follows script)

:: S30-OpenAFS-MapUserDrives.bat
::
:: setup the default environment
call \\ad.physics.unc.edu\dfs\scripts\panic\Environment.bat
echo %0 >> %FULLLOGFILE%

%nlfecho% Mapping user AFS drives ... >> %LOGFILE%

set firstcharacter=%username:~0,1%

%nlfecho% X >> %LOGFILE%
:: map X to /afs/physics.unc.edu/users/u/username
net use X: /delete
net use X: \\afs\users\%firstcharacter%\%username%

%nlfecho% W >> %LOGFILE%
:: map W to /afs/physics.unc.edu/users/u/username/Windows
net use W: /delete
net use W: \\afs\users\%firstcharacter%\%username%\Windows

echo done >> %LOGFILE%
:: end script

Environment.bat is called by many of our login and startup scripts and the 
locations of needed binaries, directories, and other variables are set 
there (so they can be adjusted for all scripts in one place). FULLLOGFILE 
is for admin diagnosis while text sent to LOGFILE is echoed to the screen 
interactively (thanks to a bit code that Rodney was kind enough to share).

Basically, mapping drives isn't hard at all, but my advice is that if 
you're building a true Windows _infrastructure_, then make sure your 
scripts are structured and manageable long-term. For instance, all of my 
startup and logon scripts are named SXX-description.bat and called in order 
by a wrapper script. Each script sources the same Environment.bat. For a 
unix admin reluctantly supporting Windows, this just makes me a happier 
admin. Any resemblance to unix rcX.d startup style is purely intentional.

Regarding mapped drives vs. UNC paths, our biggest problem is that file 
change notifications do not work on \\AFS UNC paths, as referenced in 
http://rt.central.org/rt/Ticket/Display.html?id=50864 . My understanding is 
that this will never be fixed on WinXP.

Cheers, Stephen
--
Stephen Joyce
Systems Administrator                                            P A N I C
Physics & Astronomy Department                         Physics & Astronomy
University of North Carolina at Chapel Hill         Network Infrastructure
voice: (919) 962-7214                                        and Computing
fax: (919) 962-0480                               http://www.panic.unc.edu

Don't judge a book by its movie.

On Fri, 21 Dec 2007, Rodney M. Dyer wrote:

> At 11:45 AM 12/21/2007, Dave Botsch wrote:
>> Those of you using windows and mapping a user's afs homedir to a windows 
>> drive, how are you doing it?
>
> Our xp logon scripts can see our unix passwd file so I just use some command 
> shell code something like the following...
>
>        :: get afs home directory
>        set "afs_homedir="
>
>        nlfecho Finding AFS home directory...
>        if not exist "\\afs\uncc\...\passwd" (
>                echo error.
>                echo Unable to access AFS UNIX passwd file.
>                exit /b 1
>        )
>
>        :: search password file for user's entry and get homedir
>        for /f "tokens=6 delims=:" %%i in ('findstr /i /b /c:"%UserName%:" 
> \\afs\uncc\...\passwd') do (
>                set "afs_homedir=%%i"
>        )
>
>        if not defined afs_homedir (
>                echo error.
>                echo User not found in passwd file.
>                exit /b 1
>        )
>        echo done.
>
>        :: remove the /afs and convert forward slashes to backslashes
>        set "xp_homedir=%afs_homedir:/afs=%"
>        set "xp_homedir=N:%xp_homedir:/=\%"
>
>        echo Homedir=%xp_homedir%
>
>        :: check for existance of home directory
>        nlfecho Checking AFS home directory...
>        if not exist "%xp_homedir%" (
>                echo error.
>                echo The home directory doesn't exist.
>                exit /b 1
>        )
>        echo done.
>
> Note that our users have the AD account home drive property set to something 
> like:
>
>     "n:\uncc\...\rmdyer"
>
> So the N: drive is already mapped globally when the user logs on via...
>
>     net use n: \\afs\all
>
> Of course global drives are now deprecated and are not supposed to be used, 
> but we still use them in XP.  We are working on plans to use UNC paths soon. 
> The trouble is that the xp command shell (cmd.exe) cannot use a UNC path as a 
> current directory, so I'm not sure what Microsoft "expects" us to use in the 
> Profile options dialog of the AD account options.
>
> Rodney
>
>
> _______________________________________________
> OpenAFS-info mailing list
> OpenAFS-info@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-info
>