Estou com um script que gera as configurações do Ldap + Samba no Ubuntu 9.04 server 32 bit (não sei se server para o 64 bit ) porem não estou conseguindo fazer as maquinas windows logarem atraves dele. Lembrando que tem que fazer a atualização do apt-get
Abaixo estou enviado o script gerado.
O codigo abaixo já é o script praticamente ele faz tudo sozinho
mais antes tem que gerar o arquivo ldapinstall.sh
e depois sudo chmod +x ldapinstall.sh
apos fazer isso executar o scritp.
Ai serão feitas perguntas para as configurações automaticamente e depois disso o servidor estará pronto do Ldap + Samba.
Mais como sou iniciante não estou conseguindo entende como posso adicionar os usuários e as maquinas para que seja feita o login do usuário no domino criado.
Espero que me ajudem e obrigado pela atenção.
#!/bin/bash
echo "Must enter: sudo su before running this script"
echo "continue?:"
read continue
if [ $continue != "y" ]
then exit 0
fi
clear
echo "Enter desired domain name: "
read DomainName
echo "Enter desired server(netbios) name: "
read servername
#1 ------------------------------
echo "1)install openldap"
#echo "Press any key to continue"
#read nullvar
apt-get --yes install slapd ldap-utils db4.2-util
rm -r /etc/ldap/slapd.d/
mv /etc/default/slapd /etc/default/slapd.bak
echo "
SLAPD_CONF=/etc/ldap/slapd.conf
SLAPD_USER=\"openldap\"
SLAPD_GROUP=\"openldap\"
SLAPD_PIDFILE=
SLAPD_SERVICES=\"ldap:/// ldapi:///\"
SLAPD_SENTINEL_FILE=/etc/ldap/noslapd
SLAPD_OPTIONS=\"\"
" >> /etc/default/slapd
#2 --------------------------------
echo "2) Install Samba documentation containing the Samba schema. Extract samba.schema and copy to the required system area for OpenLDAP."
#echo "Press any key to continue"
#read nullvar
apt-get --yes install samba-doc && gunzip /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz && cp -v /usr/share/doc/samba-doc/examples/LDAP/samba.schema /etc/ldap/schema
#3 ---------------------------------
echo "3) Decide on an LDAP admin password and generate a SSHA hash key for it."
#echo "Press any key to continue"
#read nullvar
export slappass=`slappasswd`
echo "4) Create an init.ldif file. Name the 4 OUs Users, Groups, Computers and Idmap for use with smbldap-tools. "
#echo "Press any key to continue"
#read nullvar
echo "
dn: dc=$DomainName
objectClass: dcObject
objectClass: organizationalUnit
dc: $DomainName
ou: $DomainName
dn: cn=admin,dc=$DomainName
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword: $slappass
dn: ou=Users,dc=$DomainName
objectClass: organizationalUnit
ou: Users
dn: ou=Groups,dc=$DomainName
objectClass: organizationalUnit
ou: Groups
dn: ou=Computers,dc=$DomainName
objectClass: organizationalUnit
ou: Computers
dn: ou=Idmap,dc=$DomainName
objectClass: organizationalUnit
ou: Idmap
">> /etc/ldap/init.ldif
mv /etc/ldap/slapd.conf /etc/ldap/slapd.conf.bak
echo "
# /etc/ldap/slapd.conf
# This is the main slapd configuration file. See slapd.conf(5) for more
# info on the configuration options.
#######################################################################
# Global Directives:
# Features to permit
#allow bind_v2
# Schema and objectClass definitions
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/samba.schema
include /etc/ldap/schema/misc.schema
# Where the pid file is put. The init.d script
# will not stop the server if you change this.
pidfile /var/run/slapd/slapd.pid
# List of arguments that were passed to the server
argsfile /var/run/slapd/slapd.args
# Read slapd.conf(5) for possible values
loglevel 0
# Where the dynamically loaded modules are stored
modulepath /usr/lib/ldap
moduleload back_bdb
# The maximum number of entries that is returned for a search operation
sizelimit 500
# The tool-threads parameter sets the actual amount of cpu's that is used
# for indexing.
tool-threads 1
#######################################################################
# Specific Backend Directives for bdb:
# Backend specific directives apply to this backend until another
# 'backend' directive occurs
backend bdb
#checkpoint 512 30
#######################################################################
# Specific Backend Directives for 'other':
# Backend specific directives apply to this backend until another
# 'backend' directive occurs
#backend <other>
#######################################################################
# Specific Directives for database #1, of type bdb:
# Database specific directives apply to this databasse until another
# 'database' directive occurs
database bdb
# The base of your directory in database #1
suffix \"dc=$DomainName\"
# rootdn directive for specifying a superuser on the database. This is needed
# for syncrepl.
rootdn \"cn=admin,dc=$DomainName\"
rootpw $slappass
# Where the database file are physically stored for database #1
directory \"/var/lib/ldap\"
# For the Debian package we use 2MB as default but be sure to update this
# value if you have plenty of RAM
dbconfig set_cachesize 0 2097152 0
# Sven Hartge reported that he had to set this value incredibly high
# to get slapd running at all. See http://bugs.debian.org/303057
# for more information.
# Number of objects that can be locked at the same time.
dbconfig set_lk_max_objects 1500
# Number of locks (both requested and granted)
dbconfig set_lk_max_locks 1500
# Number of lockers
dbconfig set_lk_max_lockers 1500
# Indexing options for database #1
#index objectClass eq, pres
index ou,cn,sn,mail,givenname eq,pres,sub
index uidNumber,gidNumber,memberUid eq,pres
index loginShell eq,pres
index uniqueMember eq,pres
index uid pres,sub,eq
index displayName pres,sub,eq
index sambaSID eq
index sambaPrimaryGroupSID eq
index sambaDomainName eq
index default sub
#index uid pres,eq,sub
# Save the time that the entry gets modified, for database #1
lastmod on
# Where to store the replica logs for database #1
# replogfile /var/lib/ldap/replog
# The userPassword by default can be changed
# by the entry owning it if they are authenticated.
# Others should not be able to see it, except the
# admin entry below
# These access lines apply to database #1 only
access to attrs=userPassword,shadowLastChange
by dn=\"cn=admin,dc=$DomainName\" write
by anonymous auth
by self write
by * none
# Ensure read access to the base for things like
# supportedSASLMechanisms. Without this you may
# have problems with SASL not knowing what
# mechanisms are available and the like.
# Note that this is covered by the 'access to *'
# ACL below too but if you change that as people
# are wont to do you'll still need this if you
# want SASL (and possible other things) to work
# happily.
access to dn.base=\"\" by * read
# The admin dn has full write access, everyone else
# can read everything.
access to *
by dn=\"cn=admin,dc=$DomainName\" write
by * read
# For Netscape Roaming support, each user gets a roaming
# profile for which they have write access to
#access to dn=\".*,ou=Roaming,o=morsnet\"
# by dn=\"cn=admin,dc=example,dc=ch\" write
# by dnattr=owner write
#######################################################################
# Specific Directives for database #2, of type 'other' (can be bdb too):
# Database specific directives apply to this databasse until another
# 'database' directive occurs
#database <other>
# The base of your directory for database #2
#suffix \"dc=debian,dc=org\"
">> /etc/ldap/slapd.conf
#5
echo "5) Initialise OpenLDAP database .. "
#echo "Press any key to continue"
#read nullvar
/etc/init.d/slapd stop
rm -rf /var/lib/ldap/*
cd /etc/ldap
slapadd -v -l init.ldif
chown -R openldap:openldap /var/lib/ldap
/etc/init.d/slapd start
ldapsearch -xLLL -b "dc=$DomainName"
#6
echo "Install and Configure Samba"
#echo "Press any key to continue"
#read nullvar
apt-get -y install libtalloc1 smbclient samba libpam-smbpass
#7
echo "7) Create Samba folders that have not been automatically created .."
#echo "Press any key to continue"
#read nullvar
mkdir -v /var/lib/samba/profiles
chmod 777 /var/lib/samba/profiles
mkdir -v -p /var/lib/samba/netlogon
#8
echo "8) Edit /etc/samba/smb.conf - so it looks EXACTLY like this but replacing your domain name"
#echo "Press any key to continue"
#read nullvar
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
echo "
[global]
# Domain name ..
workgroup = $DomainName
# Server name - as seen by Windows PCs ..
netbios name = $servername
# Be a PDC ..
domain logons = Yes
domain master = Yes
# Be a WINS server ..
wins support = true
obey pam restrictions = Yes
dns proxy = No
os level = 35
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
pam password change = Yes
# Allows users on WinXP PCs to change their password when they press Ctrl-Alt-Del
unix password sync = no
ldap passwd sync = yes
# Printing from PCs will go via CUPS ..
load printers = yes
printing = cups
printcap name = cups
# Use LDAP for Samba user accounts and groups ..
passdb backend = ldapsam:ldap://localhost
# This must match init.ldif ..
ldap suffix = dc=$DomainName
# The password for cn=admin MUST be stored in /etc/samba/secrets.tdb
# This is done by running 'sudo smbpasswd -w'.
ldap admin dn = cn=admin,dc=$DomainName
# 4 OUs that Samba uses when creating user accounts, computer accounts, etc.
# (Because we are using smbldap-tools, call them 'Users', 'Computers', etc.)
ldap machine suffix = ou=Computers
ldap user suffix = ou=Users
ldap group suffix = ou=Groups
ldap idmap suffix = ou=Idmap
# Samba and LDAP server are on the same server in this example.
ldap ssl = no
# Scripts for Samba to use if it creates users, groups, etc.
add user script = /usr/sbin/smbldap-useradd -m '%u'
delete user script = /usr/sbin/smbldap-userdel %u
add group script = /usr/sbin/smbldap-groupadd -p '%g'
delete group script = /usr/sbin/smbldap-groupdel '%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'
# Script that Samba users when a PC joins the domain ..
# (when changing 'Computer Properties' on the PC)
add machine script = /usr/sbin/smbldap-useradd -w '%u'
# Values used when a new user is created ..
# (Note: '%L' does not work properly with smbldap-tools 0.9.4-1)
logon drive =
logon home =
logon path =
logon script =
# This is required for Windows XP client ..
server signing = auto
server schannel = Auto
[homes]
comment = Home Directories
valid users = %S
read only = No
browseable = No
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
admin users = root
guest ok = Yes
browseable = No
[Profiles]
comment = Roaming Profile Share
# would probably change this to elsewhere in a production system ..
path = /var/lib/samba/profiles
read only = No
profile acls = Yes
browsable = No
[printers]
comment = All Printers
path = /var/spool/samba
use client driver = Yes
create mask = 0600
guest ok = Yes
printable = Yes
browseable = No
public = yes
writable = yes
admin users = root
write list = root
[print$]
comment = Printer Drivers Share
path = /var/lib/samba/printers
write list = root
create mask = 0664
directory mask = 0775
admin users = root
">> /etc/samba/smb.conf
#9
echo "9) Write password for the LDAP admin account (eg. cn=admin,dc=ubuntudom) into /etc/samba/secrets.tdb"
#echo "Press any key to continue"
#read nullvar
smbpasswd -W
#10
echo "10) Restart Samba .."
#echo "Press any key to continue"
#read nullvar
/etc/init.d/samba restart
#11
echo "11) Use the SMB client to check that the Samba server is responding correctly."
#echo "Press any key to continue"
#read nullvar
smbclient -L localhost -U anonymous%
#12
echo "12) Install smbldap-tools and extract the configure.pl script."
#echo "Press any key to continue"
#read nullvar
apt-get -y install smbldap-tools
gunzip /usr/share/doc/smbldap-tools/configure.pl.gz
chmod +x /usr/share/doc/smbldap-tools/configure.pl
#13
echo "13) Before configuring smbldap-tools, check that Samba is running and the Windows domain SID can be retrieved."
#echo "Press any key to continue"
#read nullvar
ps -e | grep -i "smb"
net getlocalsid
#14
echo "14) Populate the LDAP database with essential Samba entries. This includes the creation of standard groups, such as Administrators and Domain Users.
Accept defaults to the following questions except the 2 prompts for passwords, enter the LDAP admin password.
"
#echo "Press any key to continue"
#read blankvar
/usr/share/doc/smbldap-tools/configure.pl
# either run this or
#14)
echo "14) Populate the LDAP database with essential Samba entries. This includes the creation of standard groups, such as Administrators and Domain Users."
#echo "Press any key to continue"
#read blankvar
smbldap-populate
#-------
#dpkg-reconfigure slapd moved from step 14
#-------
#15)
echo "15) Following this, stop the LDAP server, run slapindex, and restart the LDAP server."
#echo "Press any key to continue"
#read blankvar
/etc/init.d/slapd stop
slapindex
chown openldap:openldap /var/lib/ldap/*
/etc/init.d/slapd start
#16)
echo "16) Add Test Account"
#echo "Press any key to continue"
#read blankvar
echo "Adding user david"
smbldap-useradd -a -m -P david
#password = david
#17) add test account
echo "add david and root as Administrators"
sudo /usr/sbin/smbldap-groupmod -m 'david' 'Administrators'
sudo /usr/sbin/smbldap-groupmod -m 'root' 'Administrators'
#18) prove test account
echo "prove test account"
smbldap-groupshow Administrators
#19
echo "19) add ldap auth on clients
Answer with the following(write down if necessary):
#ldap://$servername
#dc=$DomainName
#3
#yes
#no
#cn=admin,dc=$DomainName
#<enter the LDAP admin password>
Press Enter to continue.
"
read nullvar
apt-get -y install ldap-auth-client
auth-client-config -t nss -p lac_ldap
pam-auth-update ldap
#20)
getent group
#RESTART
echo "press any key to restart now"
read restartvar
shutdown now -r