So problem in way to adding a computer to MMC and/or adding PC to Domain. MMC uses "standard" scheme in plugins/samba/init.py
...
user_info = {
'objectclass':('account', 'posixAccount', 'top'),
...
and then waits that then PC will join to Domain "smbpasswd -a -m " will modify objectclass and other attributes to meet SAMBA requirements.
But smbpasswd doesn't do this! Because computer account MUST already have objectclass sambaSamAccount to able find entry to change. So it look like closed circle.
I did the next steps to resolve it
1. Fix in /usr/sbin/smbldap_tools.pm function sub add_posix_machine
sub add_posix_machine
{
my ($user,$uid,$gid,$wait) = @_;
if (!defined $wait) {
$wait=0;
}
# bind to a directory with dn and password
my $add = $ldap->add ( "uid=$user,$config{computersdn}",
attr => [
'objectclass' => ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount'],
#'objectclass' => ['top', 'account', 'posixAccount'],
'cn' => "$user",
'sn' => "$user",
'uid' => "$user",
'uidNumber' => "$uid",
'gidNumber' => "$gid",
'homeDirectory' => '/dev/null',
'loginShell' => '/bin/false',
'description' => 'Computer',
'gecos' => 'Computer',
]
);
$add->code && warn "failed to add entry: ", $add->error ;
sleep($wait);
return 1;
}
2. Then moved up function sub add_samba_machine below to sub add_posix_machine , and moved sub add_samba_machine_smbpasswd that was there before (so now functions going that add_posix_machine first, then add_samba_machine and then add_samba_machine_smbpasswd, other code I leave untouched)