Samba NT Domain Controller

所属分类: 操作系统 / unix linux 阅读数: 101
收藏 0 赞 0 分享
Currently, Samba can go beyond merely emulating Windows shares to actually acting as the Primary Domain Controller for your Windows network. Of course, Samba can also become a NT domain member. In this article we shall look at both these options. 


The domain concept is much better than the traditional workgroup concept. One of the primary benefits is having a centralized password database on the Primary Domain Controller. Once authenticated, you can access any of the shares in the domain, without having to re-authenticate yourself. 

If you're unfamiliar with Samba, then we've got a couple of good howto's that you can refer to. Look for links to them at the bottom of the article. 

Samba as a NT Domain Member 

Samba emulates a NT workstation when becoming part of the domain. So, the first thing you need to do is create a machine account for your Samba machine on the domain controller. In NT you would use the program Server Manager for Domains to create the account. Once the account is created, all you need to add are the following lines to your smb.conf file under the global section. 


# Your Workgroup or Domain that you want
# to login to
workgroup = FREEOS

# Tell Samba to talk to domain controller
# for authentication
security = domain

# Specify the server to get authenticate 
# from. You can specify the 
# NetBIOS # names of the servers or simply 
# put in a "*" here to let 
# Samba find the server through broadcast 
password server = PS1 PS2 

# Make sure Samba is using encrypted 
# passwords
encrypt passwords = yes

Now stop the Samba daemons

/etc/rc.d/init.d/smb stop

Give the following command to join the 
NT Domain

smbpasswd -j DOMAIN -r DOMAINPDC


DOMAIN here is the domain that you want to log on to. DOMAINPDC is the primary domain controller for that domain. You will then see a message saying, 揓oined domain DOMAIN? 

Now start your SMB and NMB daemons. 

/etc/rc.d/init.d/smb start 

That was all about joining an NT domain. Setting up Samba as your Primary Domain Controller is not very difficult. 

Samba as Primary Domain Controller 

Add the following to the global section of your smb.conf file. 


# The domain you want to be a PDC for
workgroup = SIMPLE

# Tell Samba to use domain logons
domain logons = yes

# User-level security. Users must 
# authenticate themselves with
# valid username and password
security = user

# Set to yes so that nmbd participates 
# in local master browser
# elections
local master = yes 

# Set Os level value to make sure nmbd 
# wins local browse master 
# elections. 65 should beat everyone 
# according to the man page
os level = 65

# Give nmbd an advantage in local 
# master browser elections
preferred master = yes

# Set so that nmbd claims a unique 
# NetBIOS name identifying it as 
# a domain master
domain master = yes

# The following share is required to support
# domain logons. The directory may be 
# created anywhere on your system. Make 
# sure the share is non-writeable and also
# not a public share.
[netlogon]
comment = The domain logon service
path = /usr/local/samba/netlogon
public = no
writeable = no

The next thing to do is create the users on the Samba server that is to act as the domain controller. You can do this using the useradd command. 

useradd ?g smbuser ?d /dev/null ?s /dev/null ntuser 

As you can see, both shell and home directory for ntuser is set to /dev/null. If your Windows users are not required to access the Unix box, you should use the above to deny access to the machine. Passwords are also not required to be set because Samba keeps the password hash in a separate file specified in the configuration file. 


# Path to Samba password file
# Make sure only root has read/write access
smb passwd file = /usr/local/samba/smbpasswd

After adding a user (you can also use vipw to add a user), you need to add the user to the samba password database. 

搒mbpasswd 朼?will add all users in Unix passwd file to smbpasswd file. The usage and syntax is similar to the Unix passwd command. To change a users?password use 搒mbpasswd username? 

That will be enough for Samba to start authenticating Windows 9X clients. For NT workstations, some more work is to be done. You have to create a machine account for each NT client that will logon. A machine account is simply a regular /etc/passwd entry, with a ??appended to the name of the NT machine. 

useradd -g smbuser -杁 /dev/null -杝 /dev/null ntclient$ 

Now add it to the password database 

smbpasswd 朼 杕 ntclient (the $ at the end is not required) 

Samba can now accept logons from a NT client. 

As you can see, configuring samba as a domain controller and domain member is a fairly easy job. The flip side is that since samba is the result of major amounts of hacking and reverse engineering, it doesn't have all the functionality of a proper domain controller. There is an alternative branch, Samba TNG that adds more functionality in this area. 
更多精彩内容其他人还在看

教你隐藏Linux的命令行历史

有的时候你可能不想让一些命令记录你的的命令行历史中,本文整理了多种方法让你可以参考。
收藏 0 赞 0 分享

怎样在Linux上录制你的终端操作及回放

在这次的文章中,我们将简单的了解一下如何在Linux上录制和回放终端会话及以gif格式记录的方法。
收藏 0 赞 0 分享

SUSE Linux登录出现黑屏解决方法

登录linux时出现黑屏的找到这篇解决SUSE的黑屏问题
收藏 0 赞 0 分享

个人学习Linux知识总结第1/4页

个人学习linux经常用到的小知识,方便大家以后查阅
收藏 0 赞 0 分享

Linux 下rename 命令的用法第1/2页

刚学习linux的时候,对文件重命名首先想到的就是rename命令,但是按照在windows下对文件重命名的方式试了N多次都没有反应,在网上一搜索,发现很多人都对rename命令知之甚少,甚至有一部分人说linux下没有rename命令,建议大家用mv命令。鉴于此,于是man r
收藏 0 赞 0 分享

Centos 源

Centos操作说明
收藏 0 赞 0 分享

linux备份文件命令收集

收集一些linux下实现文件备份
收藏 0 赞 0 分享

Linux rdesktop操作系统下远程登录Windows XP桌面

众所周知XP下有"远程桌面连接"用来远程登录桌面,设置也非常简单。那有没有什么办法在linux下远程登录到XP呢?有。用rdesktop这个linux下的软件就能实现。
收藏 0 赞 0 分享

Linux操作系统添加新硬盘方法

linux下添加硬盘的方法
收藏 0 赞 0 分享

CentOS 5.1 4.6最新官方下载地址列表

最近公司接触到centos系统,于是找了下,不太容易找到,所以我直接把官方的下载地址,给贴出来了,方便以后下载
收藏 0 赞 0 分享
查看更多