
ntlogon.py v0.11.0 Copyright 2006 by Gabriel Orozco.
--------------------------------------------------

This program is released under the terms of the GNU Public License,
This program has NO WARRANTY of any kind, use at your own risk.

======
TO DO:
======
* Fix or workaround bugs.
* Recode for clean it.
* Make usage samples.

=====
BUGS:
=====
* All known fixed.

============
INTRODUCTION
============
As my experience with Linux and Samba increased, I had no trouble whipping up
a custom Perl, Python or Bash script to create Samba Logon Scripts, but I
noticed that I changed things from place to place, and that my users had *no*
chance of ever figuring out how to modify those scripts themselves.

In an attempt to create a company wide standard that both my co-workers and my
customers could *easily* modify I hit upon the scheme I used here.

I settled on an INI file feel, because most who have experience with Win boxes
have some concept of INI files.

============
INSTALLATION
============
The distribution archive contains three files:

README			This file
ntlogon.py		The actual Python script (place in /usr/local/samba/bin)
ntlogon.conf	A sample configuration file (place in /etc)

This script was created using Python v1.5.2, and I believe it uses only
standard libraries, altough now it requieres also some base os commands,
like groups, cut, and grep.

Your smb.conf file needs to contain a netlogon section similar to the 
following (These settings *are not* normal on a RH box. These settings
are all based on the excellent book that I learned Samba from: Samba
Integrating Unix and Windows by John D. Blair. It is somewhat out of 
date now, but that's the history of the strange file locations):

[netlogon]
    path = /usr/local/samba/netlogon
    writeable = no
    guest ok = no
    root preexec = /usr/local/samba/bin/ntlogon.py --os=%m --localuser=%u
    root postexec = rm /usr/local/samba/netlogon/%U.bat

======
USAGE
======
PLEASE SEE ntlogon.conf FOR A DETAILED CONFIGURATION EXAMPLE

This programme will build a Windows NT logon script for users connecting
to a Samba server. Samba macros that are curently understood:

   %U user name
   %u linux local user name (needed)
   %a machine architecture
   %m machine netbios name

This programme reads a configuration that looks strikingly similar to both
the Samba configuration file, and a DOS "boot menu" AUTOEXEC.BAT file.

The default file name is /etc/ntlogon.conf (though I really think it ought
to be called ntlogon.batch!) You may change the filename by using the -f
or --templatefile startup option.

The default netlogon directory is /usr/local/samba/netlogon though this
can be changed with the -d or --dir startup option.
                                              
The default batch file name generated is username.bat if no username is
specified the default value is logon.bat (e.g., if --user=fred is specified
on the command line then the logon script generated will be stored in 
fred.bat)

Use the --debug option to print the logon script to screen instead of the 
output file

Use the --pause option to place a pause statement between each line of the
script to assist in debugging a logon script.
 
The file is divided into sections that have headers in square brackets

[Global]
[User-username]
[Group-groupname]
[OS-osname]
[Footer]

The file may also contain user defined substitution macros. They are
defined by placing the macro name on the left side of an equal sign,
and the substitution text on the right side of the equal sign. They
are also case sensitive:

MAINDRIVE = G:
USERDRIVE = U:
SERVERNAME = myservername

They are referenced by prepending a "%" sign to the variable name:

NET USE %USERDRIVE \\%SERVERNAME\usershare /YES

In the following case note that \\servername will not work, because the 
macro processor is case sensitive, and will not find the lowercase name
along with the lack of the % before the name:

NET USE %MAINDRIVE \\servername\mainshare /YES


The correct one should be:

NET USE %MAINDRIVE \\%SERVERNAME\mainshare /YES

IMPORTANT:

Please do not forget you need to join the windows machine to the domain, or the
script will not be run in the client. nonetheless, it will be generated and can
be used if you make a link into your "Startup" menu pointing to 
\\%SERVERNAME\NETLOGON\username.bat


==============
SPECIAL THANKS
==============
Nick Lopez <kimo_sabe@atdot.org> for the net bios name patch.



===================
CONTACT INFORMATION
===================
Author	        : Timothy Grant (rhacer)
Maintainer      : Gabriel Orozco Ruiz Velazco (redimido)
ntlogon website : http://redimido.glo.org.mx/ntlogon/
I can be reached at redimido@glo.org.mx and/or gorv@myrealbox.com

-------------

Please feel free to contact me with any suggestions, improvements, bugs you
might find.
