summaryrefslogtreecommitdiff
path: root/examples/LDAP/convertSambaAccount
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-07-16 05:34:56 +0000
committerGerald Carter <jerry@samba.org>2003-07-16 05:34:56 +0000
commit4a090ba06a54f5da179ac02bb307cc03d08831bf (patch)
treeed652ef36be7f16682c358816334f969a22f1c27 /examples/LDAP/convertSambaAccount
parent95fe82670032a3a43571b46d7bbf2c26bc8cdcd9 (diff)
downloadsamba-4a090ba06a54f5da179ac02bb307cc03d08831bf.tar.gz
samba-4a090ba06a54f5da179ac02bb307cc03d08831bf.tar.bz2
samba-4a090ba06a54f5da179ac02bb307cc03d08831bf.zip
trying to get HEAD building again. If you want the code
prior to this merge, checkout HEAD_PRE_3_0_0_BETA_3_MERGE (This used to be commit adb98e7b7cd0f025b52c570e4034eebf4047b1ad)
Diffstat (limited to 'examples/LDAP/convertSambaAccount')
-rwxr-xr-xexamples/LDAP/convertSambaAccount56
1 files changed, 34 insertions, 22 deletions
diff --git a/examples/LDAP/convertSambaAccount b/examples/LDAP/convertSambaAccount
index f5b49ff095..223c43eada 100755
--- a/examples/LDAP/convertSambaAccount
+++ b/examples/LDAP/convertSambaAccount
@@ -15,8 +15,8 @@ use Net::LDAP::LDIF;
my ( $domain, $domsid );
my ( $ldif, $ldif2 );
my ( $entry, @objclasses, $obj );
-my ( $is_samba_account );
-my ( %attr_map, $key );
+my ( $is_samba_account, $is_samba_group );
+my ( %attr_map, %group_attr_map, $key );
if ( $#ARGV != 2 ) {
print "Usage: convertSambaAccount domain_sid input_ldif output_ldif\n";
@@ -41,6 +41,11 @@ if ( $#ARGV != 2 ) {
acctFlags => 'sambaAcctFlags',
);
+%group_attr_map = (
+ ntSid => 'sambaSID',
+ ntGroupType => 'sambaGroupType',
+);
+
$domsid = $ARGV[0];
$ldif = Net::LDAP::LDIF->new ($ARGV[1], "r")
@@ -65,37 +70,44 @@ while ( !$ldif->eof ) {
##
@objclasses = $entry->get_value( "objectClass" );
undef ( $is_samba_account );
+ undef ( $is_samba_group );
foreach $obj ( @objclasses ) {
if ( "$obj" eq "sambaAccount" ) {
$is_samba_account = 1;
+ } elsif ( "$obj" eq "sambaGroupMapping" ) {
+ $is_samba_group = 1;
}
}
- if ( !defined ( $is_samba_account ) ) {
- $ldif2->write_entry( $entry );
- next;
- }
-
- ##
- ## start editing the sambaAccount
- ##
+ if ( defined ( $is_samba_account ) ) {
+ ##
+ ## start editing the sambaAccount
+ ##
- $entry->delete( 'objectclass' => [ 'sambaAccount' ] );
- $entry->add( 'objectclass' => 'sambaSamAccount' );
+ $entry->delete( 'objectclass' => [ 'sambaAccount' ] );
+ $entry->add( 'objectclass' => 'sambaSamAccount' );
- $entry->add( 'sambaSID' => $domsid."-".$entry->get_value( "rid" ) );
- $entry->delete( 'rid' );
+ $entry->add( 'sambaSID' => $domsid."-".$entry->get_value( "rid" ) );
+ $entry->delete( 'rid' );
- if ( $entry->get_value( "primaryGroupID" ) ) {
- $entry->add( 'sambaPrimaryGroupSID' => $domsid."-".$entry->get_value( "primaryGroupID" ) );
- $entry->delete( 'primaryGroupID' );
- }
+ if ( $entry->get_value( "primaryGroupID" ) ) {
+ $entry->add( 'sambaPrimaryGroupSID' => $domsid."-".$entry->get_value( "primaryGroupID" ) );
+ $entry->delete( 'primaryGroupID' );
+ }
- foreach $key ( keys %attr_map ) {
- if ( $entry->get_value($key) ) {
- $entry->add( $attr_map{$key} => $entry->get_value($key) );
- $entry->delete( $key );
+ foreach $key ( keys %attr_map ) {
+ if ( defined($entry->get_value($key)) ) {
+ $entry->add( $attr_map{$key} => $entry->get_value($key) );
+ $entry->delete( $key );
+ }
+ }
+ } elsif ( defined ( $is_samba_group ) ) {
+ foreach $key ( keys %group_attr_map ) {
+ if ( defined($entry->get_value($key)) ) {
+ $entry->add( $group_attr_map{$key} => $entry->get_value($key) );
+ $entry->delete( $key );
+ }
}
}