There is my perl script for update Display Name in Identities from LDAP:
#!/usr/bin/perl
use DBI;
use Net::LDAP;
my $server = "dc.domain.local";
my $ldap = Net::LDAP->new( $server ) or die $@;
$ldap->bind ('user@domain.local',password => 'Password_for_user');
my $host = "localhost";
my $port = "3306";
my $db = "roundcubemail";
my $user = "mysql_root_user";
my $pass = "password_for_mysql_root_user";
$dbh = DBI->connect("DBI:mysql:$db:$host:$port",$user,$pass);
$dbh->do("SET NAMES 'utf8'");
$sth = $dbh->prepare("SELECT email FROM identities");
$sth->execute;
while ($ref = $sth->fetchrow_arrayref) {
my $smail = "$$ref[0]";
my $result = $ldap->search(base => "dc=domain,dc=local", scope => "subtree", filter => "(&(objectclass=user)(objectcategory=Person)(mail=$smail))" );
die $result->error if $result->code;
foreach my $entry ($result->entries) {
$FIO=$entry->get_value("displayName"),
($umail=$entry->get_value("mail") || '');
}
my $query="UPDATE identities SET name = '$FIO' WHERE email = '$umail'";
print $query;
print "\n";
my $sth = $dbh->prepare($query);
$sth->execute() or die $DBI::errstr;
}
$rc = $sth->finish;
$rc = $dbh->disconnect;
$ldap->unbind;