Search This Blog

Friday, December 23, 2011

How To Add Users To Your Samba Domain - PART13


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 created previously, and the third is to map a Windows drive letter to the user's Linux home directory. Let's 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 in to the Samba server via telnet or ssh.

Create the user

To create the user, use the command:
[root@bigboy tmp]# useradd -g 100 peter

Give them a Linux Password

Giving them a Linux password is only necessary if the user needs to log into the Samba server directly. If the user does, use this method:
[root@bigboy tmp]# passwd peter
Changing password for user peter.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bigboy tmp]#

Mapping The Linux Users To An smbpassword

Next, you need to create Samba domain login passwords for the user
[root@bigboy 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:
  1. Let the user log into the domain.
  2. Right-click on the "My Computer" icon on the desktop.
  3. Click on "Map Network Drive".
  4. Select a drive letter.
  5. Browse to the HOMENET domain, then the Samba server, then the user's home directory.
  6. Click on the check box "Reconnect at Logon", to make the change permanent

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.
1. Create a master logon batch file for all users
[root@bigboy tmp]# vi /home/samba/netlogon/login.bat
2. Add the following lines to mount the user's share as drive P: (for private).
REM Drive Mapping Script
net use P: \\bigboy\
3. Make the file world readable using:
[root@bigboy tmp]# chmod 644 /home/samba/netlogon/login.bat
4. Linux and Windows format text files slightly differ. 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.
[root@bigboy tmp]# unix2dos /home/samba/netlogon/login.bat
unix2dos: converting file /home/samba/netlogon/login.bat
to DOS format ...
[root@bigboy tmp]#
5. The final step is to edit your smb.conf file's [global] section have a valid entry for the logon script parameter. This can be done using SWAT via the Globals menu.
[global]
  logon script = login.bat
Now your users will have additional disk space available on a Windows P: drive whenever they login.

No comments: