爱生活,爱IT
全部博文(436)
分类:
2007-04-22 20:02:22
# Global parameters
[# Global parameters
[global]
# MODIFY
workgroup = BIGTIME
# MODIFY
netbios name = linus
# MODIFY
server string = Linus Samba Server
passdb backend = ldapsam:ldap://127.0.0.1/
# By default run with minimal logging. However, if you need to debug
# 5 is a fairly verbose logging level.
#log level = 5
log file = /var/log/samba/log.%m
max log size = 50
time server = Yes
add user script = /var/lib/samba/sbin/smbldap-useradd -a '%u'
delete user script = /var/lib/samba/sbin/smbldap-userdel '%u'
add group script = /var/lib/samba/sbin/smbldap-groupadd -p '%g'
delete group script = /var/lib/samba/sbin/smbldap-groupdel '%g'
add user to group script = /var/lib/samba/sbin/smbldap-groupmod -m '%u''%g'
delete user from group script = /var/lib/samba/sbin/smbldap-groupmod -x '%u' '%g'
set primary group script = /var/lib/samba/sbin/smbldap-usermod -g '%g' '%u'
add machine script = /var/lib/samba/sbin/smbldap-useradd -w '%u'
# Personally, I do not like roaming profiles because they take up too
# much space on my server. As such, I disable roaming profiles by
# setting the following two variables to null
logon path =
logon home =
logon drive = H:
domain logons = Yes
preferred master = Yes
domain master = Yes
wins support = Yes
# MODIFY
ldap admin dn = cn=Manager,dc=somedomain,dc=com
ldap group suffix = ou=Groups
ldap idmap suffix = ou=Idmap
ldap machine suffix = ou=Computers
ldap passwd sync = Yes
# MODIFY
ldap suffix = dc=somedomain,dc=com
ldap user suffix = ou=Users
idmap backend = ldap:ldap://127.0.0.1
idmap uid = 10000-20000
idmap gid = 10000-20000
# The next three blocks define the shared drives that we will be exposing. They are all
# nearly identical. The important thing to note is that all files on these drives are
# readable and writeable by any user in that group.
[netlogon]
path = /var/lib/samba/netlogon/scripts
browseable = No
root preexec = /var/lib/samba/netlogon/scripts/logon.pl %U %I
# MODIFY
[marketing]
comment = Marketing material
path = /home/marketing
# Any files written to this drive will have this user group. Since this is a
# *shared* drive all users should have permission to read/write/remove any file.
# If you do not agree you will probably want to remove the "force group" line
force group = marketing
read only = No
create mask = 0770
directory mask = 0770
browseable = No
# MODIFY
[engineering]
comment = Common material
path = /home/engineering
path = /home/marketing
# Any files written to this drive will have this user group. Since this is a
# *shared* drive all users should have permission to read/write/remove any file.
# If you do not agree you will probably want to remove the "force group" line
force group = engineering
read only = No
create mask = 0770
directory mask = 0770
browseable = No
# MODIFY
[management]
comment = Management Data
path = /home/management
path = /home/marketing
# Any files written to this drive will have this user group. Since this is a
# *shared* drive all users should have permission to read/write/remove any file.
# If you do not agree you will probably want to remove the "force group" line
force group = management
read only = No
create mask = 0770
directory mask = 0770 |
#!/usr/bin/perl
use strict;
# Set the permissions on any file we create to 640 (i.e. -rw-r--r--)
umask(022);
my $NETLOGON_DIR = "/var/lib/samba/netlogon/scripts";
my $LOG_DIR = "/var/log/samba";
my $SERVERNAME = "linus";
## You will need to modify this hash to match your mountpoints.
my %MOUNTPOINTS = (
"engineering" => "NET USE W: \\$SERVERNAME\engineering /YESrn",
"marketing" => "NET USE W: \\$SERVERNAME\marketing /YESrn",
"management" => "NET USE W: \\$SERVERNAME\management /YESrn"
);
## Make sure that there is a user name and that it contains a valid
## user name string (i.e. no invalid chars).
if ($#ARGV != 1 ||
$ARGV[0] =~ /[^a-zA-Z0-9-_]/) {
exit(1);
}
# Make sure that the user exists and log attempts with invalid IDs
my $uid = getpwnam($ARGV[0]);
if ($uid == /[^0-9]/){
my $now = localtime;
open LOG, ">>$LOG_DIR/log.netlogon";
print LOG "$now";
print LOG " - Error: Unknown user $ARGV[0] logged into $SERVERNAME from $ARGV[1]n";
close LOG;
exit(1);
}
# Log the logon attempt
my $now = localtime;
open LOG, ">>$LOG_DIR/log.netlogon";
print LOG "$now";
print LOG " - User $ARGV[0] logged into $SERVERNAME from $ARGV[1]n";
close LOG;
## Create a custom logon batch file.
open FH, ">$NETLOGON_DIR/$ARGV[0].cmd";
# Turn echo off
print FH "@ECHO OFFrn";
# Synchronize time between Windows client and Linux server.
print FH "NET TIME \\$SERVERNAME /SET /YESrn";
foreach my $key (keys(%MOUNTPOINTS)) {
if (isMember($ARGV[0], $key)) {
# Put mount points in file
print FH "$MOUNTPOINTS{$key}";
}
}
close FH;
# Checks to see if the given user is a member of
# the given group.
# Returns 1 if true and 0 otherwise.
sub isMember{
my ($user, $group) = @_;
my ($name, $passwd, $gid, $members) = getgrnam($group);
my @members = split /s+/, $members;
for(@members){
if ($user eq $_) {
return 1;
}
}
return 0;
} |
[root@linus sbin]# ./configure.pl
If you need to change this, enter the full directory path, then press enter to continue.
Smbldap-tools Configuration Directory Path [/etc/opt/IDEALX/smbldap-tools/] >
/var/lib/samba/sbin
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Let's start configuring the smbldap-tools scripts ...
. workgroup name: name of the domain Samba act as a PDC
workgroup name [BIGTIME] >
. netbios name: netbios name of the samba controler
netbios name [linus] >
. logon drive: local path to which the home directory will be connected (for NT
Workstations). Ex: 'H:'
logon drive [H:] >
. logon home: home directory location (for Win95/98 or NT Workstation).
(use %U as username) Ex:'\linus%U'
logon home (press the "." character if you don't want homeDirectory) [\linus%U]
> .
. logon path: directory where roaming profiles are stored. Ex:'\linusprofiles%U'
logon path (press the "." character if you don't want roaming profile)
[\linusprofiles%U] > .
. home directory prefix (use %U as username) [/home/%U] >
. default users' homeDirectory mode [700] >
. default user netlogon script (use %U as username) [%U.cmd] > ""
default password validation time (time in days) [45] >
. ldap suffix [dc=somedomain,dc=com] >
. ldap group suffix [ou=Groups] >
. ldap user suffix [ou=Users] >
. ldap machine suffix [ou=Computers] >
. Idmap suffix [ou=Idmap] >
. sambaUnixIdPooldn: object where you want to store the next uidNumber
and gidNumber available for new users and groups
sambaUnixIdPooldn object (relative to ${suffix}) [sambaDomainName=BIGTIME] >
. ldap master server: IP adress or DNS name of the master (writable) ldap server
ldap master server [127.0.0.1] >
. ldap master port [389] >
. ldap master bind dn [cn=Manager,dc=somedomain,dc=com] >
. ldap master bind password [] >
. ldap slave server: IP adress or DNS name of the slave ldap server: can also be the
master one
ldap slave server [127.0.0.1] >
. ldap slave port [389] >
. ldap slave bind dn [cn=Manager,dc=somedomain,dc=com] >
. ldap slave bind password [] >
. ldap tls support (1/0) [0] > 1
. How to verify the server's certificate (none, optional or require) [require] >
. CA certificate file [/var/lib/samba/sbin//ca.pem] > /etc/openldap/cacerts/cacert.pem
. certificate to use to connect to the ldap server
[/var/lib/samba/sbin//smbldap-tools.pem] >
. key certificate to use to connect to the ldap server
[/var/lib/samba/sbin//smbldap-tools.key] >
. SID for domain BIGTIME: SID of the domain (can be obtained with
'net getlocalsid linus')
SID for domain BIGTIME [S-1-5-21-1030832020-2822878261-2997333186] >
. unix password encryption: encryption used for unix passwords
unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA) [SSHA] > MD5
. default user gidNumber [513] >
. default computer gidNumber [515] >
. default login shell [/bin/bash] >
. default skeleton directory [/etc/skel] >
. default domain name to append to mail adress [] > somedomain.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
backup old configuration files:
/var/lib/samba/sbin/smbldap.conf->/var/lib/samba/sbin/smbldap.conf.old
/var/lib/samba/sbin/smbldap_bind.conf->/var/lib/samba/sbin/smbldap_bind.conf.old
writing new configuration file:
/var/lib/samba/sbin/smbldap.conf done.
/var/lib/samba/sbin/smbldap_bind.conf done. |
[root@linus sbin]# ./smbldap-populate
Populating LDAP directory for domain BIGTIME (S-1-5-21-1030832020-2822878261-2997333186)
(using builtin directory structure)
LDAP config host: 127.0.0.1
port: 389
version: 3
timeout: 60
adding new entry: dc=somedomain,dc=com
adding new entry: ou=Users,dc=somedomain,dc=com
adding new entry: ou=Groups,dc=somedomain,dc=com
adding new entry: ou=Computers,dc=somedomain,dc=com
adding new entry: uid=root,ou=Users,dc=somedomain,dc=com
adding new entry: uid=nobody,ou=Users,dc=somedomain,dc=com
adding new entry: cn=Domain Admins,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Domain Users,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Domain Guests,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Domain Computers,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Administrators,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Account Operators,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Print Operators,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Backup Operators,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=Replicators,ou=Groups,dc=somedomain,dc=com
adding new entry: cn=NextFreeUnixId,dc=somedomain,dc=com
Please provide a password for the domain root:
LDAP config host: 127.0.0.1
port: 389
version: 3
timeout: 60
Changing password for root
New password :
Retype new password : |
cd /var/lib/samba/sbin
./smbldap-groupadd engineering
./smbldap-groupadd marketing
./smbldap-groupadd management
./smbldap-useradd -s /sbin/nologin -m -g engineering engineering
./smbldap-useradd -s /sbin/nologin -m -g marketing marketing
./smbldap-useradd -s /sbin/nologin -m -g management management |
cd /var/lib/samba/sbin
./smbldap-useradd -a -G "Domain Users",engineering dilbert
./smbldap-passwd dilbert
./smbldap-useradd -a -G "Domain Users",engineering wally
./smbldap-passwd wally
./smbldap-useradd -a -G "Domain Users",marketing catbert
./smbldap-passwd catbert
./smbldap-useradd -a -G "Domain Users",marketing,management,engineering boss
./smbldap-passwd boss |