Skip to content
Home ยป Using Samba to Authenticate Against a Windows Server

Using Samba to Authenticate Against a Windows Server

Using Samba to Authenticate Against a Windows Server


1. Introduction

In enterprise environments, instead of managing separate user accounts on Linux, Samba can be configured to authenticate users against a Windows Server (Active Directory).

๐Ÿ‘‰ This allows:

  • Centralized authentication
  • Single login credentials
  • Better security and management

๐Ÿ‘‰ In simple words:
Linux + Samba uses Windows Server (AD) for login authentication


2. What is Active Directory (AD)?

Active Directory (AD) is a directory service by Microsoft that:

  • Stores user accounts
  • Manages authentication
  • Controls permissions across network

๐Ÿ“Œ Samba integrates with AD to use these accounts.


3. Authentication Methods in Samba

MethodDescription
Local authenticationLinux users
Domain authenticationWindows AD users
LDAP authenticationExternal directory

๐Ÿ‘‰ Here we focus on Domain Authentication (AD)


4. Requirements

  • Windows Server with Active Directory Domain Controller
  • Linux system with Samba installed
  • Network connectivity
  • Time synchronization (very important)
  • Domain admin credentials

5. Required Packages

Ubuntu / Debian

sudo apt install samba winbind libnss-winbind libpam-winbind krb5-user

RHEL / CentOS

sudo yum install samba samba-winbind krb5-workstation

6. Configure Samba for AD Authentication

Edit Samba configuration:

sudo vi /etc/samba/smb.conf

Basic Configuration

[global]
   workgroup = MYDOMAIN
   security = ads
   realm = MYDOMAIN.COM

   winbind use default domain = yes
   winbind offline logon = yes

   idmap config * : backend = tdb
   idmap config * : range = 10000-20000

7. Configure Kerberos

Edit:

/etc/krb5.conf

Example:

[libdefaults]
 default_realm = MYDOMAIN.COM

[realms]

MYDOMAIN.COM = { kdc = dc.mydomain.com }


8. Join Linux to Windows Domain

sudo net ads join -U Administrator

๐Ÿ‘‰ Enter domain admin password


9. Start Required Services

sudo systemctl restart smbd
sudo systemctl restart winbind

Enable:

sudo systemctl enable smbd
sudo systemctl enable winbind

10. Verify Domain Integration

Check Users

wbinfo -u

Check Groups

wbinfo -g

Test Authentication

getent passwd

11. Allow Domain Users to Access Samba Share

Example:

[shared]
   path = /srv/samba/shared
   valid users = @"MYDOMAIN\Domain Users"
   writable = yes

12. Authentication Flow

User โ†’ Samba โ†’ Winbind โ†’ Active Directory โ†’ Authentication โ†’ Access Granted

13. Advantages

  • Centralized user management
  • Single sign-on (SSO)
  • Strong security
  • Easy administration

14. Common Issues

IssueSolution
Domain join failsCheck DNS
Authentication failsSync time
Users not visibleCheck winbind
Permission deniedVerify group mapping

15. Real-World Example

  • Corporate network:
    • Windows Server manages users
    • Linux Samba server provides file sharing
    • Employees use same login credentials

16. Conclusion

Using Samba with Windows Server (Active Directory) enables centralized authentication and seamless integration between Linux and Windows systems. It is widely used in enterprise environments for secure and efficient user management.