#!/usr/bin/perl
use Net::LDAP;
$Ad = Net::LDAP->new("sogolab.com", version => 3, port => 389) or die("failed $!");
print "Failed connecting" if(!$Ad);
## bind as an admin or someone who has privileges to create an user
$b = $Ad->bind(dn => 'CN=Administrator,CN=Users,DC=sogolab,DC=com', password => 'xxxxxxx') or die("failed $!; ".$b->error);
$result = $Ad->add( 'cn=Thomas T,cn=Users,DC=sogolab,DC=com',
attr => [
'cn' => 'Thomas T',
'sn' => 'Thomas',
'mail' => 'thomas@sogolab.com',
'targetAddress' => 'SMTP:sam@kmail.com',
'mAPIRecipient' => 'FALSE',
'mailNickname' => 'Thomas',
'internetEncoding' => '1310720',
'objectclass' => ['top','person','organizationalPerson','contact' ]]
);
$result->code && warn "failed to add entry: ", $result->error ;
No comments:
Post a Comment