Bước 1 : Stop dịch vụ LDAP lại :
ERROR
Error looking for next uid in cn=NextFreeUnixId,dc=no-dns,dc=co,dc=uk:No such
object at /usr/lib/perl5/vendor_perl/5.8.8/smbldap_tools.pm line 1071
yum install -y postfix dovecot squirrelmail
vim /etc/postfix/main.cf
#tên máy chủ gởi mail
70 myhostname = mail.dnson.local
#domain dùng để gởi nhận mail
77 mydomain = dnson.local
#giữ nguyên thông tin domain khi gởi
93 myorigin = $mydomain
#tất cả các interface nhận mail
110 inet_interfaces = all
#chỉ nhận mail đế domain của tôi
157 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#các IP được phép relay qua server mail
255 mynetworks = 10.10.10.0/24 , 127.0.0.0/8
vim /etc/dovecot.conf
45 passdb ldap {
46 # Path for LDAP configuration file, see doc/dovecot-ldap-example.conf
47 args = /etc/dovecot-ldap.conf
48 }
vim /etc/dovecot-ldap.conf
#IP
mail serverhosts = 10.10.10.254
base = dc=dnson.local,dc=localldap_version = 3
vim /etc/squirrelmail/config.php
30 $domain = 'dnson.local';
31 $imapServerAddress = 'mail.dnson.local';
vim /etc/openldap/slapd.conf
79 # rootdn can always read and write EVERYTHING!
80 access to * by * write //[COLOR="#FF0000"]bạn thêm dòng này vào[/COLOR]
81 #######################################################################
82 # ldbm and/or bdb database definitions
service postfix start
service dovecot start
IP : 10.10.10.10
yum install openldap* -y
slappasswd
vim /etc/openldap/slapd.conf
vim /etc/openldap/ldap.conf
vim /etc/nsswitch.conf
cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
service ldap start
chkconfig ldap on
cd /usr/share/openldap/migration
vim migrate_common.ph
./migrate_base.pl > /root/base.ldif-Trích xuất user hệ thống ra 1 file alluser.ldif
./migrate_passwd.pl /etc/passwd > /root/alluser.ldif-Lấy user hệ thống add vào ldap
ldapadd -c -x -D "cn=Manager,dc=abc,dc=com" -W -f /root/base.ldif
https://lh6.googleusercontent.com/-O-0AwXxTWyk/T8sHbrAUmYI/AAAAAAAABIg/t33E2gaqQF0/s779/conmotit_6.jpg
ldapadd -c -x -D "cn=Manager,dc=abc,dc=com" -W -f /root/alluser.ldif
slapcat
useradd -g users ldapuser
passwd ldapuser
grep "ldapuser" /etc/passwd | tee /root/a.info
./migrate_passwd.pl /root/a.info > /root/alluser.ldif
ldapadd -c -x -D "cn=Manager,dc=abc,dc=com" -W -f /root/alluser.ldif
finger
pdbedit -P "min password length" -C 10
pdbedit -P "user must logon to change password" -C 2
net sam set pwdmustchangenow kiemtra yes
wget http://wpkg.org/files/stable/1.3.x/wpkg-1.3.0-bin.zip
unzip wpkg-1.3.0-bin.zip
cp wpkg /wpkg
chmod 777 -R /wpkg
cd /wpkg
vim hosts.xml
<?xml version="1.0" encoding="UTF-8"?>
<hosts:wpkg xmlns:hosts="http://www.wpkg.org/hosts" xmlns:wpkg="http://www.wpkg.org/wpkg"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wpkg.org/hosts xsd/hosts.xsd ">
<!--
Specifies a match for host name "hostname" and assigns profile "custom"
to this host.
-->
<host name="ad.dnson.local" profile-id="kiemtra">
</host>
<host name=".+" profile-id="other" />
</hosts:wpkg>
<host name="host1" profile-id="custom1" >
<profile id="addons1"/>
<profile id="addons2"/>
</host>
vim packages.xml
<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package
id="ccleaner"
name="CCleaner"
revision="3.24.1850"
reboot="false"
priority="1090">
<variable name="version" value="3.24" />
<check type="uninstall" condition="exists" path="CCleaner" />
<check type="file" condition="versiongreaterorequal" path="%PROGRAMFILES%\CCleaner\CCleaner.exe" value="3.24.1850"/>
<install cmd='\\\\10.10.10.1\wpkg\ccleaner\ccsetup324.exe /S' />
<upgrade cmd='\\\\10.10.10.1\wpkg\ccleaner\ccsetup324.exe /S' />
<remove cmd='"%ProgramFiles%\CCleaner\uninst.exe" /S' />
</package>
</packages>
vim profiles.xml
<?xml version="1.0" encoding="UTF-8"?>
<profiles:profiles xmlns:profiles="http://www.wpkg.org/profiles"
xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wpkg.org/profiles xsd/profiles.xsd ">
<!--
Default set of software to be assigned to all hosts.
-->
<profile id="kiemtra">
<package package-id="ccleaner" />
</profile>
</profiles:profiles>
mkdir /wpkg/ccleaner
cd /wpkg/ccleaner
wget http://software-files-a.cnet.com/s/software/12/80/04/63/ccsetup324.exe?token=1352029193_b3bd187a14a183cb3f6edab884d7a7ff&lop=link&ptype=3001&ontid=18512&siteId=4&edId=3&spi=6203e1f74a225a810cfedd11ac3a0f6c&pid=12800463&psid=10315544&fileName=ccsetup324.exe
script /wpkg/wpkg.js
cd /usr/share/openldap/migration
vim migrate_common.ph
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "dnson.local"; sửa lại cho giống domain của bạn
# Default base
$DEFAULT_BASE = "dc=dnson,dc=local";sửa lại cho giống domain của bạn
./migrate_base.pl > base.ldif
./migrate_passwd.pl passwd > alluser.ldif
./migrate_group.pl group > group.ldif
ldapadd -c -x -D "cn=Manager,dc=dnson,dc=local" -W -f base.ldif
ldapadd -c -x -D "cn=Manager,dc=dnson,dc=local" -W -f alluser.ldif
ldapadd -c -x -D "cn=Manager,dc=dnson,dc=local" -W -f group.ldif
smbldap-populate
smbldap-useradd -a -G "Domain Users" -m -s /bin/bash -d /home/kiemtra -F "" -P kiemtra
smbldap-passwd u1
service iptables stop
chkconfig iptables off
setenforce permissive
service smb restart
service nmb restart
service ldap restart
service named restart
the following error occurred attempting to join the domain access denied
smbldap-useradd -a -G "Domain Users" -m -s /bin/bash -d /home/kiemtra -F "" -P kiemtra
vim /etc/smbldap-tools/smbldap_bind.conf
slaveDN="cn=Manager,dc=dnson,dc=local"slavePw="123456"masterDN="cn=Manager,dc=dnson,dc=local"masterPw="123"
vim /etc/smbldap-tools/smbldap.conf
sambaDomain="dnson.local"
################################################################################ LDAP Configuration###############################################################################
# Notes: to use to dual ldap servers backend for Samba, you must patch# Samba with the dual-head patch from IDEALX. If not using this patch# just use the same server for slaveLDAP and masterLDAP.# Those two servers declarations can also be used when you have# . one master LDAP server where all writing operations must be done# . one slave LDAP server where all reading operations must be done# (typically a replication directory)
# Slave LDAP server# Ex: slaveLDAP=127.0.0.1# If not defined, parameter is set to "127.0.0.1"slaveLDAP="slave.dnson.local"
# Slave LDAP port# If not defined, parameter is set to "389"slavePort="389"
# Master LDAP server: needed for write operations# Ex: masterLDAP=127.0.0.1# If not defined, parameter is set to "127.0.0.1"masterLDAP="ad.dnson.local"
# Master LDAP port# If not defined, parameter is set to "389"masterPort="389"
# Use TLS for LDAP# If set to 1, this option will use start_tls for connection# (you should also used the port 389)# If not defined, parameter is set to "1"ldapTLS="0"
# How to verify the server's certificate (none, optional or require)# see "man Net::LDAP" in start_tls section for more detailsverify="none"
# CA certificate# see "man Net::LDAP" in start_tls section for more detailscafile=""
# certificate to use to connect to the ldap server# see "man Net::LDAP" in start_tls section for more detailsclientcert=""
# key certificate to use to connect to the ldap server# see "man Net::LDAP" in start_tls section for more detailsclientkey=""
# LDAP Suffix# Ex: suffix=dc=IDEALX,dc=ORGsuffix="dc=dnson,dc=local"
# Where are stored Users# Ex: usersdn="ou=Users,dc=IDEALX,dc=ORG"# Warning: if 'suffix' is not set here, you must set the full dn for usersdnusersdn="ou=Users,${suffix}"
# Where are stored Computers# Ex: computersdn="ou=Computers,dc=IDEALX,dc=ORG"# Warning: if 'suffix' is not set here, you must set the full dn for computersdncomputersdn="ou=Computers,${suffix}"
# Where are stored Groups# Ex: groupsdn="ou=Groups,dc=IDEALX,dc=ORG"# Warning: if 'suffix' is not set here, you must set the full dn for groupsdngroupsdn="ou=Groups,${suffix}"
# Where are stored Idmap entries (used if samba is a domain member server)# Ex: groupsdn="ou=Idmap,dc=IDEALX,dc=ORG"# Warning: if 'suffix' is not set here, you must set the full dn for idmapdnidmapdn="ou=Idmap,${suffix}"
# Where to store next uidNumber and gidNumber available for new users and groups# If not defined, entries are stored in sambaDomainName object.# Ex: sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}"# Ex: sambaUnixIdPooldn="cn=NextFreeUnixId,${suffix}"sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}"
# Default scope Usedscope="sub"
# Unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA, CLEARTEXT)hash_encrypt="SSHA"
# if hash_encrypt is set to CRYPT, you may set a salt format.# default is "%s", but many systems will generate MD5 hashed# passwords if you use "$1$%.8s". This parameter is optional!crypt_salt_format=""
################################################################################ Unix Accounts Configuration###############################################################################
# Login defs# Default Login Shell# Ex: userLoginShell="/bin/bash" userLoginShell="/bin/bash"
# Home directory# Ex: userHome="/home/%U"userHome="/home/%U"
# Default mode used for user homeDirectoryuserHomeDirectoryMode="700"
# GecosuserGecos="System User"
# Default User (POSIX and Samba) GIDdefaultUserGid="513"
# Default Computer (Samba) GIDdefaultComputerGid="515"
# Skel dirskeletonDir="/etc/skel"
# Default password validation time (time in days) Comment the next line if# you don't want password to be enable for defaultMaxPasswordAge days (be# careful to the sambaPwdMustChange attribute's value)defaultMaxPasswordAge="45"
################################################################################ SAMBA Configuration###############################################################################
# The UNC path to home drives location (%U username substitution)# Just set it to a null string if you want to use the smb.conf 'logon home'# directive and/or disable roaming profiles# Ex: userSmbHome="\\PDC-SMB3\%U"userSmbHome="\\10.10.10.1\%U"
# The UNC path to profiles locations (%U username substitution)# Just set it to a null string if you want to use the smb.conf 'logon path'# directive and/or disable roaming profiles# Ex: userProfile="\\PDC-SMB3\profiles\%U"userProfile="\\10.10.10.1\profiles\%U"
# The default Home Drive Letter mapping# (will be automatically mapped at logon time if home directory exist)# Ex: userHomeDrive="H:"userHomeDrive="H:"
# The default user netlogon script name (%U username substitution)# if not used, will be automatically username.cmd# make sure script file is edited under dos# Ex: userScript="startup.cmd" # make sure script file is edited under dosuserScript="logon.bat"# Domain appended to the users "mail"-attribute# when smbldap-useradd -M is used# Ex: mailDomain="idealx.com"mailDomain="dnson.local"
################################################################################ SMBLDAP-TOOLS Configuration (default are ok for a RedHat)###############################################################################
# Allows not to use smbpasswd (if with_smbpasswd="0" in smbldap.conf) but# prefer Crypt::SmbHash librarywith_smbpasswd="0"smbpasswd="/usr/bin/smbpasswd"
# Allows not to use slappasswd (if with_slappasswd="0" in smbldap.conf)# but prefer Crypt:: librarieswith_slappasswd="0"slappasswd="/usr/sbin/slappasswd"
# comment out the following line to get rid of the default banner# no_banner="1"
mv /etc/samba/smb.conf /etc/samba/smb.conf.backup
cp /usr/share/doc/smbldap-tools-0.9.6/smb.conf /etc/samba/
vim /etc/samba/smb.conf
[global]
ldap ssl = No
nt acl support = No
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
workgroup = dnson.local đây là cái mà ta nhập domain bên client để join
realm = dnson.local
netbios name = ldap
security = user
enable privileges = yes
server string = Samba Server %v
encrypt passwords = Yes
interfaces = eth0
bind interfaces only = yes
username map = /etc/samba/smbusers
unix password sync = yes
ldap passwd sync = Yes
passwd program = /usr/sbin/smbldap-passwd -u "%u"
passwd chat = "Changing *\nNew password*" %n\n "*Retype new password*" %n\n"
log level = 1
syslog = 0
log file = /var/log/samba/log.%U
max log size = 100000
time server = Yes
smb ports = 139 445
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
mangling method = hash2
Dos charset = 850
Unix charset = ISO8859-1
logon script = logon.bat
logon drive = H:
logon home = \\%L\%U
logon path = \\%L\profiles\%U
domain logons = Yes
domain master = Yes
os level = 65
preferred master = Yes
wins support = yes
passdb backend = ldapsam:ldap://10.10.10.1/
ldap admin dn = cn=Manager,dc=dnson,dc=local
ldap suffix = dc=dnson,dc=local
ldap group suffix = ou=Groups
ldap user suffix = ou=Users
ldap machine suffix = ou=Computers
add user script = /usr/sbin/smbldap-useradd -m "%u"
delete user script = /usr/sbin/smbldap-userdel "%u"
add machine script = /usr/sbin/smbldap-useradd -t 0 -w "%u"
add group script = /usr/sbin/smbldap-groupadd -p "%g"
add user to group script = /usr/sbin/smbldap-groupmod -m "%u" "%g"
delete user from group script = /usr/sbin/smbldap-groupmod -x "%u" "%g"
set primary group script = /usr/sbin/smbldap-usermod -g '%g' '%u'
# printers configuration load printers = Yes
create mask = 0640
directory mask = 0750
nt acl support = No
printing = cups
printcap name = cups
deadtime = 10
guest account = nobody
map to guest = Bad User
dont descend = /proc,/dev,/etc,/lib,/lost+found,/initrd
show add printer wizard = yes
; to maintain capital letters in shortcuts in any of the profile folders:^M
preserve case = yes
short preserve case = yes
case sensitive = no idmap uid = 10000-20000
idmap gid = 10000-20000
[netlogon]
path = /home/netlogon/
comment = Network Logon Service
guest ok = No
locking = No
[profiles] comment = roaming profile share
path = /home/profiles
read only = No
create mask = 0600
directory mask = 0700
browseable = No
profile acls = yes
force user = %U
valid users = %U
csc policy = disable
[homes]
comment = Home Directory
browseable = No
valid users = %U
read only = no
create mask = 1770
directory mask = 1770
mkdir /home/netlogonmkdir /home/profiles
chmod 1777 /home/profiles/
service smb startservice nmb startchkconfig smb onchkconfig nmb on
smbpasswd -w 123456
net getlocalsid
vim /etc/smbldap-tools/smbldap.conf
SID ="thêm cái mã đó vô chỗ này."
slappasswd
vim /etc/openldap/slapd.conf
include /etc/openldap/schema/core.schemainclude /etc/openldap/schema/cosine.schemainclude /etc/openldap/schema/inetorgperson.schemainclude /etc/openldap/schema/nis.schemainclude /etc/openldap/schema/samba.schema đây là dòng thêm vào.gọi file cấu hình mẫu của hệ thống
allow bind_v2
loglevel -1
pidfile /var/run/openldap/slapd.pidargsfile /var/run/openldap/slapd.args
######################################################################## ldbm and/or bdb database definitions#######################################################################
database bdbsuffix "dc=dnson,dc=local"rootdn "cn=Manager,dc=dnson,dc=local"rootpw {SSHA}uUNBHS/G3Gv3M/NY9k0yJplWK4pV32SE dán cái mã ở trên vào chỗ này
directory /var/lib/ldap
index objectClass pres,eq#index ou,cn,mail,surname,givenname eq,pres,subindex cn,sn,uid,displayName pres,sub,eqindex uidNumber,gidNumber eqindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,subindex sambaSID,sambaPrimaryGroupSID,sambaDomainName eq đây là dòng thêm vàoindex default sub đây là dòng thêm vào
vim /etc/openldap/ldap.conf
BASE dc=dnson,dc=local
URI ldap://10.10.10.1:389
TLS_CACERTDIR /etc/openldap/cacerts
vim /etc/ldap.conf
base dc=dnson,dc=local
rootbinddn cn=Manager,dc=dnson,dc=local
timelimit 120
bind_timelimit 120
idle_timelimit 3600
nss_base_passwd ou=Users,dc=dnson,dc=local?one
nss_base_passwd ou=Computers,dc=dnson,dc=local?one
nss_base_group ou=Groups,dc=dnson,dc=local?one
nss_base_shadow ou=Users,dc=dnson,dc=local?one
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat, radiusd,news,mailman,nscd,gdm
uri ldap://10.10.10.1:389
ssl no
tls_cacertdir /etc/openldap/cacerts
pam_password crypt
vim /etc/nsswitch.conf
33 passwd : files ldap
34 shadow: files ldap
35 group: files ldap
cp /usr/share/doc/samba-3.0.33/LDAP/samba.schema /etc/openldap/schema/
cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
setup
vim /etc/pam.d/system-auth
session optional pam_mkhomedir.so skel=/etc/skel umask=077
service ldap start
service nscd start
chkconfig ldap on
chkconfig nscd on