patch to fix import2_smbpasswd.pl for new schema
Brad Langhorst
brad at langhorst.com
Sat Apr 13 22:54:02 GMT 2002
this can be applied to 2.2.4pre (and probably HEAD too though i've not
tried that yet)
it imports /updates my openldap 2 database from /etc/smbpasswd
but I did not test the creating a new account but it should work fine
brad
46c47,51
< filter =>
"(&(|(objectclass=posixAccount)(objectclass=smbPasswordEntry))(uid=$smbentry[0]))"
---
> filter => "(&
>
(|(objectclass=posixAccount)
>
(objectclass=sambaAccount)
> )(uid=$smbentry[0])
> )"
49a55,56
> ##add the required stuff from posix account
> ## cn uid uidNumber gidNumber homeDirectory
52,61c59,77
< attrs => [
< uid => $smbentry[0],
< uidNumber => @getpwinfo[2],
< lmPassword => $smbentry[2],
< ntPassword => $smbentry[3],
< acctFlags => $smbentry[4],
< pwdLastSet => substr($smbentry[5],4),
< objectclass => [ 'top',
'smbPasswordEntry' ]
< ]
< );
---
> attrs => [#cn =>
@getpwinfo[4], #GECOS field from getpwnam
> #uid => $smbentry[0],
> #uidNumber =>
@getpwinfo[2],
> #gidNumber =>
@getpwinfo[3],
> #homeDirectory =>
@getpwinfo[5],
> rid =>
@getpwinfo[2]*2+1000,
> primaryGroupID =>
@getpwinfo[3]*2+1001,
> logonTime => 0,
> logoffTime => 2147483647,
> kickoffTime => 2147483647,
> pwdCanChange => 0,
> pwdMustChange => 2147483647,
> lmPassword => $smbentry[2],
> ntPassword => $smbentry[3],
> acctFlags => $smbentry[4],
> pwdLastSet =>
hex(substr($smbentry[5],4)),
> objectclass => [ 'top',
'sambaAccount' ]
> ]
> );
71c87
< ## Add the objectclass: smbPasswordEntry attribute if it's
not there
---
> ## Add the objectclass: sambaAccount attribute if it's not
there
75,78c91,94
< if ( lc($item) eq "smbpasswordentry" ) {
< print $item . "\n";
< $flag = 0;
< }
---
> if ( lc($item) eq "sambaaccount" ) {
> #print $item . "\n";
> $flag = 0;
> }
81,82c97
< $entry->add(objectclass => "smbPasswordEntry");
< }
---
> ## probably the fields don't exist if the objectclass
doesn't exist
84,89c99,126
< ## Set the other attribute values
< $entry->replace(lmPassword => $smbentry[2],
< ntPassword => $smbentry[3],
< acctFlags => $smbentry[4],
< pwdLastSet => substr($smbentry[5],4)
< );
---
> $entry->add(objectclass => "sambaAccount");
> ## replace works b/c everything is there but with empty
values
> $entry->replace(rid => @getpwinfo[2]*2+1000,
> uidNumber => @getpwinfo[2],
> primaryGroupID => @getpwinfo[3]*2+1001,
> logonTime => 0,
> logoffTime => 2147483647,
> kickoffTime => 2147483647,
> pwdCanChange => 0,
> pwdMustChange => 2147483647,
> lmPassword => $smbentry[2],
> ntPassword => $smbentry[3],
> acctFlags => $smbentry[4],
> pwdLastSet => hex(substr($smbentry[5],4))
> );
> } else { ## sambaAccount is here, update with values from
smbpasswd
>
> ## Set the other attribute values from smbpasswd and
/etc/passwd
> ## other fields not updated since we don't have that info
> $entry->replace(uidNumber => @getpwinfo[2],
> rid => @getpwinfo[2]*2+1000,
> primaryGroupID => @getpwinfo[3]*2+1001,
> lmPassword => $smbentry[2],
> ntPassword => $smbentry[3],
> acctFlags => $smbentry[4],
> pwdLastSet => hex(substr($smbentry[5],4))
> );
> }
94c131
< print "Error updating $smbentry[0]!\n";
---
> print "Error updating $smbentry[0]! code: ".
$updatemesg->code ."\n";
More information about the samba-technical
mailing list