The LDAP support in current release unattended is broken, because there
is no /etc/protocols file.  I added this to my config.pl, because I
didn't feel like rebuilding the images, and putting it in
linuxaux/etc/protocols didn't work...
 
open(PROTO, "> /etc/protocols");
 
print PROTO "ip 0 IP\n";
print PROTO "icmp 1 ICMP\n";
print PROTO "tcp 6 TCP\n";
print PROTO "udp 17 UDP\n";
close PROTO;
 
I'm sure the correct fix is nice and simple however :-)

With this, I can do a lookup in LDAP for the macAddress, and find the
registered name for the machine.  I intend to use if for OS selection
and other things shortly.  We should develop a common 'unattended'
schema, to save each site inventing their own.  

$u->{'UserData'}->{'ComputerName'} =
 sub {
     my $macaddr = $u->{'_meta'}->{'macaddr'};
     my $ds= Net::LDAP->new('ldap.internal.hawkerc.net.') or die "$@";
                                                                                
     my $basedn = "dc=hawkerc,dc=net";
                                                                                
     $ds->bind() || die "bind failed!";
                                                                                
     my $attrs = [ 'cn', 'macAddress' ];
                                                                                
     my $splitmac = join(':',split(/(..)/, lc($macaddr)));
     $splitmac =~ /\:(.*)/;
     $splitmac = $1;
     $splitmac =~ s/\:\:/\:/g;
                                                                                
     my $mesg = $ds->search(
                            base => $basedn,
                            filter =>
"(&(&(objectClass=ieee802device)(macAddress=$splitmac))(cn=*))",
                            attrs => $attrs,
                            );
                                                                                
     if ($mesg->count != 1) {
         die "Could not find computer in LDAP! (found mac address ".
$splitmac." ".$mesg->count." times in ldap)";
     }
     return $mesg->entry(0)->get_value('cn');
 };


The unattended system just saved me a lot of work last night - I rebuilt
a whole lab of computers, with most of the time taken by teaching them
to boot of the network and entering passwords (which I don't trust in an
anonymous share...).  

Thanks!

Andrew Bartlett
-- 
Andrew Bartlett                                 [EMAIL PROTECTED]
Authentication Developer, Samba Team            http://samba.org
Student Network Administrator, Hawker College   [EMAIL PROTECTED]

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to