Hi everyone, new day, new goals

I think about this mail :  
http://www.mail-archive.com/packetfence-devel%40lists.sourceforge.net/msg00496.html

And I discover that an LDAP exist and I can log my user with it !

So I copy Ldap.pm to "ecole.pm" make some modification in pf.conf, and  
ad this function at the end :

sub getNodeAttributes{
  my ($this) = @_;

  return ( category => 'ecole');
}

(and I make some thinks in pf::vlan::custom) I works fine (thanks Devel guide)

but, I would try to make more.

I create in ecole.pm this function but I can call it, I need the username...

sub getEmployeeType{
        my ($this, $username) = @_ ;

        my $connection = Net::LDAP->new($LDAPServer);
     if (!defined($connection)) {
       $logger->error("Unable to connect to '$LDAPServer'");
       return $FALSE;
     }

     my $result = $connection->bind;
     if ($result->is_error) {
       $logger->error("Unable to bind");
       return $FALSE;
     }



        my $result = $connection->search(
             base => $LDAPUserBase,
             filter => "($LDAPUserKey=$username)",
         scope => $LDAPUserScope,
             attrs => [ 'employeeType' ]
         );
        if ($result->is_error) {
        $logger->info("Some trouble to get EmployeeType with the  
username : $username");
        $this->_setLastError('Some trouble to get EmployeeType with the  
username : $username');
        return $FALSE;
        }

        $connection->unbind;

        my @entries = $result->entries;

        #Double foreach, if someone found something more clean...
        foreach my $entr ( @entries ) {
        foreach my $attr ( $entr->attributes ){
                return $entr->get_value( $attr);
         }
     }
}


So do you have an idea ?

Thanks, Rémi Desgrange




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
PacketFence-devel mailing list
PacketFence-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/packetfence-devel

Reply via email to