#! /usr/bin/perl sub DN () { 'cn=admin,dc=foo,dc=com' } sub PASSWORD () { 'mypass' } sub SERVER () { 'localhost' } use Carp; use Net::LDAP; # Create connection to the LDAP server and bind authoratively using # administrator credentials my $ldap = Net::LDAP->new( SERVER ); unless ( defined $ldap ) { croak( 'Cannot create connection to LDAP server -- ', $! ); } $ldap->bind ( 'dn' => DN, 'password' => PASSWORD ); my $result = $ldap->add ( 'cn=foo,ou=v_domains,ou=postfix,ou=system_services,dc=foo,dc=com', 'attr' => [ 'cn' => 'foo', 'objectClass' => 'inetLocalMailRecipient', 'mailLocalAddress' => 'test001@foo.com, xmbox.com', 'mailRoutingAddress' => 'foo' ] ); $ldap->unbind;