A perl script to read the LDAP ‘networkAddress’ attribute of a server or user object from an eDirectory LDAP server and get the TCP/IP address in decimal dot notation.
The network address attribute when read via LDAP is in the form-
LDAP Format, String:
taggedData = uint32String “#” octetstring
byte 0 = uint32String = Address Type: eg. 1 = IP Address (user); 9 = TCP Address (server)
byte 1 = char = “#” – separator
byte 2+ = octetstring – the ordinal value of the address
The following instructions assume that you have a working LDAP server and Perl installed with the Net::LDAP module http://ldap.perl.org/ . Of course, the LDAP ‘networkAddress’ attribute must be visible for your LDAP proxy user.
This script can be used a command line tool or called from another script by passing the following arguments:
– LDAP server qualified DNS name or IP address
– Base OU for the LDAP search, o=myorg
– CN of the object look up the IP address of, username or server name
In that order! eg:
netaddr.pl (ldap server) (base dn) (object)