Home > LINUX > Samba Active Directory Integration: Script tested on win 2003r2 and 2008r2

Samba Active Directory Integration: Script tested on win 2003r2 and 2008r2

  • Sharebar

What this procedure will do
If all runs well you will have a Linux machine completely integrated with your Active Directory server. The shared folders permissions will be managed from your samba server and it will use groups and users taken directly from your AD Domain Controller. Just follow this guide and use the attached script!

Preface
This procedure was tested with a Linux machine running Ubuntu10.04 and both Windows Server2003 and WindowsServer2008r2 as AD Server.

This procedure is taken from a lot of guides but you can find the best guide that I’ve could find here: http://wiki.samba.org/index.php/Samb…tive_directory

It’s perfectly explicated in all its section and it treats every part more deeply than this one. I really recommend to consult it for every doubt.

Requirements

To join your Linux machine to your Active Directory Domain you need:

access to a Windows Domain Controller with a Domain Administrator account
access to a Linux machine with administrator account (sudoer or root account)
the archive provided with this guide extracted in a folder (do not move or edit the “templates” folder or its content)

For testing I really recommend to use a Linux virtual machine for the first time if it is possible.

It’s important that the name of the machine you will add to domain has a name shorter than 15 characters. If not you must modify it in /etc/hostname and in /etc/hosts file with your preferred text editor (vi,nano,gedit) and restart the machine:
Code:

sudo nano /etc/hostname

Quote:
user-laptop
Code:

sudo nano /etc/hosts

Quote:
127.0.0.1 localhost
127.0.1.1 user-laptop
Kerberos is time-dependent, so you may have to make sure that the machine time is correct using a protocol like NTP. So synchronize your Linux machine time and date with the same NTP server of your domain with:
Code:

sudo ntpdate your.domain.ntp.server

You can also make this command running regularly with crontab:
Code:

sudo crontab -e

Quote:
# m h dom mon dow command
00 12 * * * ntpdate your.domain.ntp.server
In this way the command will run at 12:00 o’clock every day with root privilege (visit http://www.crontabrocks.org/ for more information about crontab).
It is also important that your DNS is properly configured as your domain DNS; you can do that using a network manager (like network-manager or wicd) or modifying the /etc/resolv.conf file with the proper configuration. An example:
Code:

sudo nano /etc/resolv.conf

Quote:
domain yourdomain.local
search yourdomain.local
nameserver 10.0.0.5
nameserver 10.0.0.1
Note that if you using a network manager program it’s probably that your /etc/resolv.conf configuration will be ignored and replaced by an auto-generated one.
Now test your configuration with the “nslookup” command using both server name and his IP; the result might be something like this:
Code:

nslookup 10.0.0.5

Quote:
Name: WServer2k3
Address: 10.0.0.5
Code:

nslookup WServer2k3

Quote:
Name: WServer2k3
Address: 10.0.0.5
If you changed the name maybe it’s better to reboot the machine.

Running
The first thing to do is to edit AD_join.sh variables: open it with your favorite editor
Code:

nano AD_join.sh

and modify only the variables in the first part of the script editing only between “quotation_marks”:
Quote:
SUPER_USER=”myusername”
DOMAIN=”MYDOMAIN”
FQDN_CAPITAL=”MYDOMAIN.LOCAL”
FQDN=”mydomain.local”
DOMAIN_CONTROLLER=”mydomaincontroller.domain.local ”
do not modify under the WARNING line unless you know what you’re doing
Be sure that AD_join.sh has the execution bit set. Open a terminal, change location in the containing directory, and run the script with root privilege:
Code:

cd /path/of/script/directory/AD_join
sudo chmod +x AD_join.sh

Now you can run the script
Code:

sudo ./AD_join.sh

The script will install samba, winbind and kerberos in your machine and will change the original configurations files name in *.bkp in order to preserve them (also the entire /etc/pam.d/ directory will be copied to /etc/pam.d.bkp). Then it puts the new files (smb.conf, krb5.conf, nsswitch.conf, system-auth) in proper directories and restart the necessary services.
Remember that when kerberos visual configuration appear you have to say just leaving blank the text field.

Testing and Joining
It’s time to test your configuration and try to join in your Active Directory domain.
First of all test your samba configuration file, open a terminal and digit:
Code:

testparm

If all runs well you will see your samba’s configuration. If not, the program will say you in which line of smb.conf file there is problem. In this case you can try to correct it or you can comment it out with “#” or “;”.
Note that probably Samba will warn you about “winbind separator = +” line, but that should be okay.
Now try to join domain with the command:
Code:

sudo net ads join -U your_domain_admin

Change “administrator” with proper domain’s administrator name.
If all runs well the domain’s administrator password is requested. If not, it’s possible that your network connection parameter for DNS server is not properly configured, modify your network configuration or run:
Code:

sudo net ads join -S your_server_IP_or_name -U your_domain_admin

If all it’s right you will see a “SUCCES” message in your terminal.
Reboot your machine.
Now you can test the joining with:
Code:

wbinfo -u

this gives the domain’s users list
Code:

wbinfo -g

this gives the domain’s groups list
Code:

sudo wbinfo -a your_domain_user

this checks if your_domain_user using password connect to the domain
You can also check the Winbind nsswitch module with getent:
Code:

getent passwd
getent group

Note that even if the procedure it’s a success, is not sure that “getent” command gives the expected results.
For testing your Kerberos configuration use this:
Code:

kinit your_domain_user@YOUR_DOMAIN.LOCAL

Replace “your_domain_user” with an existing user name and replace “YOUR_DOMAIN.LOCAL” with your domain name. If all is set correctly your_domain_user’s password is requested. If not a kinit error will be prompted in terminal; in this case you might check your Kerberos configuration. Remember it’s important CASE SENSITIVENESS.

Download the AD Scripts

  1. No comments yet.
  1. No trackbacks yet.

Uses wordpress plugins developed by www.wpdevelop.com Copy Protected by Chetans WP-Copyprotect.