Репозитории ALT
S: | 0.9.10-alt1 |
5.1: | 0.9.6-alt2.M51.1 |
4.1: | 0.9.4-alt1 |
4.0: | 0.9.2-alt0 |
3.0: | 0.8.5-alt1 |
Группа :: Система/Настройка/Сеть
Пакет: smbldap-tools
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: smbldap-tools-0.9.2-alt-separate_users_and_groups_in_smbldap_migrate_unix_accounts.patch
Скачать
Скачать
diff -NurpP smbldap-tools-0.9.2_org/doc/migration_scripts/smbldap-migrate-unix-accounts smbldap-tools-0.9.2/doc/migration_scripts/smbldap-migrate-unix-accounts
--- smbldap-tools-0.9.2_org/doc/migration_scripts/smbldap-migrate-unix-accounts 2006-01-03 12:57:41 +0200
+++ smbldap-tools-0.9.2/doc/migration_scripts/smbldap-migrate-unix-accounts 2006-10-09 21:45:46 +0200
@@ -24,7 +24,7 @@ sub read_shadow_file;
my %Options;
-my $ok = getopts('M:P:S:vn?hd:a', \%Options);
+my $ok = getopts('M:P:S:vn?hd:auw', \%Options);
if ( (!$ok) || ($Options{'?'}) || ($Options{'h'}) || (!keys(%Options)) ) {
print "Usage: $0 [-PSMvn?hda]\n";
@@ -36,6 +36,9 @@ if ( (!$ok) || ($Options{'?'}) || ($Opti
print " -n do everything execpt updating LDAP\n";
print " -d obj_nam delete and add (not just update) existing entry in LDAP\n";
print " -a adds sambaSamAccount objectClass\n";
+ print " -u process only people, ignore computers\n";
+ print " -w process only computers, ignore persons\n";
+
exit (1);
}
@@ -60,6 +63,7 @@ if ( $Options{'M'} ) {
}
my $ldap_master=connect_ldap_master();
+my $typeuser = undef;
while ( my $line=<$INFILE> ) {
chop($line);
@@ -67,6 +71,8 @@ while ( my $line=<$INFILE> ) {
next if ( $line =~ /^#/ );
next if ( $line =~ /^\+/ );
my $entry = undef;
+ my $login = undef;
+
if ($Options{'M'}) {
my($user,$pwd,$uid,$gid,$class,$change,$expire,$gecos,$homedir,$shell) = split(/:/,$line);
# if user is not in LDAP new entry will be created
@@ -82,6 +88,7 @@ while ( my $line=<$INFILE> ) {
# if user is not in LDAP new entry will be created
$entry = get_user_entry($ldap_master,$user);
$entry = migrate_user($entry,$user,$pwd,$uid,$gid,$gecos,$homedir,$shell,undef);
+ $login = $user;
# should I delete next functionality
# add shadow entries if also -S defined
@@ -94,6 +101,21 @@ while ( my $line=<$INFILE> ) {
# if user is not in LDAP new entry will be created
$entry = get_user_entry($ldap_master,$user);
$entry = migrate_shadow_user($entry,$user,$pwd,$lastchg,$min,$max,$warn,$inactive,$expire,$flag);
+ $login = $user;
+ }
+
+ if ($login =~ m/.*\$$/ ) { # computer
+ $typeuser = "usersdn";
+ if (defined($Options{'u'})) {
+ print "ignoring $login type: $typeuser\n";
+ next;
+ }
+ } else { # people
+ $typeuser = "computersdn";
+ if (defined($Options{'w'})) {
+ print "ignoring $login type: $typeuser\n";
+ next;
+ }
}
if ($entry) {
@@ -116,7 +138,7 @@ while ( my $line=<$INFILE> ) {
my $userRid = 2 * $userUidNumber + 1000;
# let's test if this SID already exist
my $user_sid = "$config{SID}-$userRid";
- my $test_exist_sid = does_sid_exist($user_sid,$config{usersdn});
+ my $test_exist_sid = does_sid_exist($user_sid,$config{$typeuser});
if ($test_exist_sid->count == 1) {
print "User SID already owned by\n";
# there should not exist more than one entry, but ...
@@ -230,14 +252,14 @@ sub get_user_entry
my($ldap_master,$user) = @_;
# do not use read_user_entry()
- my $mesg = $ldap_master->search( base => $config{usersdn},
+ my $mesg = $ldap_master->search( base => $config{$typeuser},
scope => 'one',
filter => "(uid=$user)"
);
my $entry;
if ( $mesg->count() != 1 ) {
$entry = Net::LDAP::Entry->new();
- $entry->dn("uid=$user,$config{usersdn}");
+ $entry->dn("uid=$user,$config{$typeuser}");
} else {
$entry = $mesg->entry(0); # ????
}