Author Topic: Identities Display Name from AD  (Read 3120 times)

Offline AnteC

  • Newbie
  • *
  • Posts: 7
Identities Display Name from AD
« 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?
 

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: Identities Display Name from AD
« Reply #1 on: July 11, 2017, 08:51:52 AM »
You can pre-fill the name for new users using new_user_identity plugin.

Offline AnteC

  • Newbie
  • *
  • Posts: 7
Re: Identities Display Name from AD
« Reply #2 on: July 11, 2017, 01:14:05 PM »
Thank you for the answer.
Please help me with correct config. Now i try:

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

my roundcube config:

Code: [Select]
...
$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.
« Last Edit: July 11, 2017, 01:17:09 PM by AnteC »

Offline AnteC

  • Newbie
  • *
  • Posts: 7
Re: Identities Display Name from AD
« Reply #3 on: July 13, 2017, 06:03:33 AM »
There is my perl script for update Display Name in Identities from LDAP:
Code: [Select]
#!/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;