[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

example code how to generate machine accounts in samba



Please find attached a short example script that adds machine
accounts to ou=machines,dc=skole,dc=skolelinux,dc=no

it is tested to produce valid entries. i dont know what samba
thinks about those entries, though.

feel free to modify the funcition ldap_add_machine in
ldap-users.pl if it does not produce proper entries for samba.
it is not used anywhere in wlus and exists purely to make your
life easier. (c:

/andreas
#!/usr/bin/perl -w

use vars qw(%text %config);
sub text{}
sub read_file{}

require '/usr/share/webmin/ldap-users/ldap-users.pl';

my $uid    = shift || die "usage: addsambamachine.pl <machine-name> <ldap-admin-passwd>\n"; 
my $rootpw = shift || die "usage: addsambamachine.pl <machine-name> <ldap-admin-passwd>\n"; 
read_adduser_config();    # puts adduser config into %config

ldap_connect(# Connect to the ldap server.
	     "ldap", 
	     "cn=admin,ou=People,dc=skole,dc=skolelinux,dc=no",
	     "dc=skole,dc=skolelinux,dc=no" , 
	     $config{'FIRST_UID'} || 10000,
	     $config{'LAST_UID'} || 29999,
	     );

my $nextid = ldap_get_newid($rootpw);

my $cn  = "$uid MachineAccount";
my $gidNumber = "100";
my $uidNumber = $nextid;

ldap_add_machine($cn, "$uid\$", $uidNumber, $gidNumber, $rootpw);

print ldap_dbg_output();

Reply to: