Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: AnteC on July 11, 2017, 08:22:38 AM

Title: Identities Display Name from AD
Post by: AnteC on July 11, 2017, 08:22:38 AM
Hello.
I have roundcube 1.3 with ldap AD address book. Dovecot also use ldap for auth
But in Identities Display Name is blank.
Is it possible to use AD displayname in this field?
Title: Re: Identities Display Name from AD
Post by: alec on July 11, 2017, 08:51:52 AM
You can pre-fill the name for new users using new_user_identity plugin.
Title: Re: Identities Display Name from AD
Post by: AnteC on July 11, 2017, 01:14:05 PM
Thank you for the answer.
Please help me with correct config. Now i try:

$config['new_user_identity_addressbook'] = 'global_ldap_abook';
$config['new_user_identity_match'] = 'name_field';
$config['new_user_identity_onlogin'] = true;


my roundcube config:

...
$config['ldap_public'] = array (
  'global_ldap_abook' =>
  array (
    'name' => 'Адресная книга',
...
    array (
      'name' => 'cn',
      'name_field' => 'displayName',
      'surname' => 'sn',
      'firstname' => 'givenName',

It didnt work now.

PS new_user_identity  is in installed plugins.
Title: Re: Identities Display Name from AD
Post by: AnteC on July 13, 2017, 06:03:33 AM
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 ('[email protected]',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;