Setting Up Samba Primary Domain Controller On Centos 7: Installation
Setting Up Samba Primary Domain Controller On Centos 7: Installation
Samba PDC:
OS: CentOS 7 Minimal server
Hostname: server.unixmen.local
IP Address: 192.168.1.150/24
Client:
OS: Windows 7 32 bit
Hostname: mywindesktop
IP Address: 192.168.1.100/24
Installation
Run the following command to install samba packages.
yum install samba* -y
Samba Configuration
Edit samba default configuration file;
vi /etc/samba/smb.conf
Find the following lines, and make the changes as shown below. Replace UNIXMEN with your own domain
name.
[Global]
workgroup = UNIXMEN
security = user
domain master = yes
domain logons = yes
local master = yes
preferred master = yes
passdb backend = tdbsam
logon path = \\%L\Profiles\%U
logon script = logon.bat
add machine script = /usr/sbin/useradd -d /dev/null -g 200 -s /sbin/nologin -M %u
[homes]
comment = Home Directories
browseable = yes
writable = yes
[printers]
comment = All Printers
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
browseable = No
writable = No
[Profiles]
path = /var/lib/samba/profiles
create mask = 0755
directory mask = 0755
writable = Yes
To make this much simple, move your old smb.conf file to a safe location.
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
vi /etc/samba/smb.conf
and copy/paste the above lines. Don’t forget to change the Domain name with your own.
Test Samba configuration file syntax errors using the following command:
testparm
[global]
workgroup = UNIXMEN
add machine script = /usr/sbin/useradd -d /dev/null -g 200 -s /sbin/nologin -M %u
logon script = logon.bat
logon path = \\%L\Profiles\%U
domain logons = Yes
preferred master = Yes
domain master = Yes
idmap config * : backend = tdb
[homes]
comment = Home Directories
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
browseable = No
[Profiles]
path = /var/lib/samba/profiles
read only = No
create mask = 0755
Create the shares with proper permissions which we have mentioned in the smb.conf file
useradd user1
useradd user2
You need to create machine account for every machine in order to allow domain login from Windows
machines. The machine account are special accounts with $ at the end, i.e. machine$. The system accounts
for machines do not need login shell neither home directory.
smbpasswd -m -a machine1$
Here, smbpasswd -m …. – tells that account will be used as NT primary domain controller (Machine
account).
Here, ‘root’ user is the administrator that can be used to join the Windows NT/2000/XP/7 systems to be part
of the domain. In this case, do not provide smbpasswd with the same password as the actual root account on
Finally start samba services and enable them to start automatically on every boot.
Firewall Configuration:
Samba uses the following Ports when runs as an Active Directory Domain Controller:
DNS 53 tcp/udp
Kerberos 88 tcp/udp
Run the following commands one by one to allow Samba ports through firewall.
firewall-cmd --reload
SELinux Configuration:
setsebool -P samba_domain_controller on
setsebool -P samba_enable_home_dirs on
Also to the Samab shares which we have defined in the smb.conf file.
If you don’t want to mess up with Firewall and SELinux, simply disable them. Restart your server once you
completed all above steps.
Now try to join the samba domain from Windows OS client using the newly created user.
"The specified domain either does not exist or could not be contacted"
To get rid of this error, open the windows registry. Go to HKEY_LOCAL_MACHINE -> SYSTEM ->
CurrentControlSet -> Services -> LanmanWorkstation -> Parameters.
Changing the Primary Domain DNS name of this computer to "" failed. The name will
remain "UNIXMEN".
The error was:
The specified domain either does not exist or could not be contacted
Download and install a hotfix from the following link to prevent this error in future.
Download Hotfix
Press CTRL+ALT+Del keys, Click Switch user, and select Other user option.
That’s it. The new user will be able to login to the domain now.
You access the samba users roaming profiles in the following location in the Samba server.
ls /var/lib/samba/profiles
Sample output:
user1.V2 user2.V2
ls /var/lib/samba/profiles/user1.V2/
Sample output:
At this stage you have a fully operational Samba Domain Controller on CentOS 7.
https://www.unixmen.com/setting-samba-primary-domain-controller-centos-7/
https://www.howtoforge.com/tutorial/samba-4-domain-controller-installation-on-centos/