How to Add Users to Your Samba Domain

How to Add Users to Your Samba Domain

Adding users to a domain has three broad phases. The first is adding a Linux user on the Samba server, the second is creating a Samba smbpasswd that maps to the new Linux user, and the third is to map a Windows drive letter to the user's Linux home directory. Take a closer look.

Adding the Users in Linux

First, go through the process of adding users in Linux just as you would normally. Passwords won't be necessary unless you want the users to log into the Samba server via TELNET or SSH.

To create the user, use the command

     [[email protected] tmp]# useradd -g 100 peter

Giving them a Linux password is necessary only if the user needs to log into the Samba server directly. If the user does, use this method:

     [[email protected] tmp]# passwd peter
     Changing password for user peter.
     New password:
     Retype new password:
     passwd: all authentication tokens updated successfully.
     [[email protected] tmp]#

Mapping the Linux Users to an smbpassword

Next, you need to create Samba domain login passwords for the user:

     [[email protected] tmp]# /usr/bin/smbpasswd -a username password

The -a switch adds the user to the /etc/smbpasswd file. Use a generic password then have users change it immediately from their workstations in the usual way.

Remember the smbpasswd sets the Windows domain login password for a user, which is different from the Linux login password to log into the Samba box.

Mapping a Private Windows Drive Share

By default, Samba automatically gives each user logged into the domain an H: drive that maps to the /home/username directory on the Linux box.

Mapping Using My Computer

If the auto-mapping doesn't work, then try:

Let the user log into the domain.

Right-click on the My Computer icon on the desktop.

Click on Map Network Drive.

Select a drive letter.

Browse to the HOMENET domain, then the Samba server, then the user's home directory.

Click on the check box Reconnect at Logon, to make the change permanent.

If you're more a typist than a clicker, try the next method.

Mapping from the Command Line

If you find the My Computer method too time consuming for dozens of users or if the PC doesn't have the feature available, then you can use the command-line method and possibly make it into a script:

Create a master logon batch file for all users.

[[email protected] tmp]# vi /home/samba/netlogon/login.bat

Add the following lines to mount the user's share as drive P: (for private):

REM Drive Mapping Script
net use P: \\bigboy\

Make the file world readable using:

[[email protected] tmp]# chmod 644 /home/samba/netlogon/login.bat

Linux and Windows format text files differ slightly. As the file resides on a Linux box, but will be interpreted by a Windows machine, you'll have to convert the file to the Windows format. Use the unix2dos command:

[[email protected] tmp]# unix2dos /home/samba/netlogon/login.bat
unix2dos: converting file /home/samba/netlogon/login.bat
 to DOS format ...
[[email protected] tmp]#

The final step is to edit your smb.conf file's [global] section to have a valid entry for the logon script parameter. This can be done using SWAT via the Globals menu.

logon script = login.bat

Now your users will have additional disk space available on a Windows P: drive whenever they login.

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows