Mantis Bugtracker          
testlink.org

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008871TestLinkLDAP authenticationpublic2020-02-18 13:542020-02-19 10:08
Reporteradam122 
Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusnewResolutionopen 
PlatformOSCentOSOS Version6.10
Product Version1.9.20 
Fixed in Version 
Summary0008871: LDAP autocreation don't fill account info
DescriptionConfigured an LDAP connection, new users log in correctly, but information about them is not filled out from LDAP. Name and surname are equal to login, email is equal to "no_mail_configured@on_ldapserver.org".

My config.inc.php:

$tlCfg->authentication['domain'] = array('DB' => array('description' => 'DB', 'allowPasswordManagement' => true) ,
                     'LDAP' => array('description' => 'LDAP', 'allowPasswordManagement' => false) );

$tlCfg->authentication['LDAP'][1]['ldap_server'] = 'ip';
$tlCfg->authentication['LDAP'][1]['ldap_port'] = 'port';
$tlCfg->authentication['LDAP'][1]['ldap_version'] = '3';
$tlCfg->authentication['LDAP'][1]['ldap_root_dn'] = 'root_dn';
$tlCfg->authentication['LDAP'][1]['ldap_bind_dn'] = 'bind_dn';
$tlCfg->authentication['LDAP'][1]['ldap_bind_passwd'] = 'password';
$tlCfg->authentication['LDAP'][1]['ldap_tls'] = false;
$tlCfg->authentication['LDAP'][1]['ldap_organization'] = ')';
$tlCfg->authentication['LDAP'][1]['ldap_uid_field'] = 'sAMAccountName';
$tlCfg->authentication['LDAP'][1]['ldap_firstname_field'] = 'givenName';
$tlCfg->authentication['LDAP'][1]['ldap_surname_field'] = 'sn';
$tlCfg->authentication['LDAP'][1]['ldap_email_field'] = 'mail';

$tlCfg->authentication['LDAP'][2]['ldap_server'] = 'ip2';
$tlCfg->authentication['LDAP'][2]['ldap_port'] = 'port2';
$tlCfg->authentication['LDAP'][2]['ldap_version'] = '3';
$tlCfg->authentication['LDAP'][2]['ldap_root_dn'] = 'root_dn2';
$tlCfg->authentication['LDAP'][2]['ldap_bind_dn'] = 'bind_dn2';
$tlCfg->authentication['LDAP'][2]['ldap_bind_passwd'] = 'password';
$tlCfg->authentication['LDAP'][2]['ldap_tls'] = false;
$tlCfg->authentication['LDAP'][2]['ldap_organization'] = '';
$tlCfg->authentication['LDAP'][2]['ldap_uid_field'] = 'uid';
$tlCfg->authentication['LDAP'][2]['ldap_firstname_field'] = 'givenName';
$tlCfg->authentication['LDAP'][2]['ldap_surname_field'] = 'sn';
$tlCfg->authentication['LDAP'][2]['ldap_email_field'] = 'mail';


$tlCfg->authentication['method'] = 'LDAP';
$tlCfg->authentication['ldap_automatic_user_creation'] = true;


Log userlog0.log:

[>>][5e4be6234f448694457384][DEFAULT][/login.php][20/Feb/18 13:26:59]
        [20/Feb/18 13:26:59][L18N][<nosession>][GUI]
                string 'unknown_authentication_method' is not localized for locale 'ru_RU' - using en_GB
        [20/Feb/18 13:26:59][L18N][<nosession>][GUI]
                string 'error_ldap_start_tls_failed' is not localized for locale 'ru_RU' - using en_GB
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_NOTICE
Undefined index: ldap - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 154
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_WARNING
Invalid argument supplied for foreach() - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 154
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_NOTICE
Undefined index: ldap - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/doAuthorize.php - Line 126
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_NOTICE
Array to string conversion - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 277
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_WARNING
ldap_unbind() expects parameter 1 to be resource, null given - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 283
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_NOTICE
Array to string conversion - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 277
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_WARNING
ldap_unbind() expects parameter 1 to be resource, null given - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 283
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_NOTICE
Array to string conversion - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 277
        [20/Feb/18 13:26:59][WARNING][<nosession>][GUI]
                E_WARNING
ldap_unbind() expects parameter 1 to be resource, null given - in /opt/testlink-1.9.15-4/apps/testlink/htdocs/lib/functions/ldap_api.php - Line 283
[<<][5e4be6234f448694457384][DEFAULT][/login.php][20/Feb/18 13:26:59][20/Feb/18 13:26:59][took 0.062856 secs]


I also added an error_log to ldap_api.php to view information on the progress of obtaining data from LDAP.

error_log("Searching for $t_search_filter", 3, "/var/testlink/my-errors.log");
error_log("$t_search_attrs", 3, "/var/testlink/my-errors.log");
error_log("ldap search failed", 3, "/var/testlink/my-errors.log");
error_log("Found value '{$t_value}' for field '{$p_field}'.", 3, "/var/testlink/my-errors.log");


In this log:

Searching for (&(=login))Arrayldap search failedSearching for (&(=login))Array
TagsNo tags attached.
Database (MySQL,Postgres,etc)MySQL + LADP
BrowserFirefox 73
PHP Version7.3.14
TestCaseID
QA Team - Task Workflow Status
Attached Files

- Relationships

-  Notes
(0029490)
adam122 (reporter)
2020-02-18 13:58

I tried to run the script from the server on which the testlink is installed. It returns all the necessary data.


<?php

$ldap_server = 'ip';
$ldap_port = 'port';
$ldap_version = '3';
$ldap_root_dn = 'root_dn';
$ldap_organization = '';
$ldap_uid_field = 'uid';
$ldap_bind_dn = 'bind_dn';
$ldap_bind_passwd = 'password';

$UserToLookFor='login';

$ldapconn = ldap_connect("ldap://$ldap_server", [^] $ldap_port) or die("Not connect: $ldaphost ");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
$ad = ldap_bind($ldapconn, $ldap_bind_dn, $ldap_bind_passwd) or die("Can't bind to ldap server");

$justthese = array("sn", "givenname", "mail");
$sr=ldap_search($ldapconn, $ldap_root_dn, "(&$ldap_organization($ldap_uid_field={$UserToLookFor}))", $justthese);
$info = ldap_get_entries($ldapconn, $sr);
print_r($info)

?>
(0029491)
adam122 (reporter)
2020-02-19 10:08

The problem was solved. You need to change ['LDAP'] to ['ldap'].

$tlCfg->authentication['domain'] = array('DB' => array('description' => 'DB', 'allowPasswordManagement' => true) ,
                     'LDAP' => array('description' => 'LDAP', 'allowPasswordManagement' => false) );

$tlCfg->authentication['ldap'][1]['ldap_server'] = 'ip';
$tlCfg->authentication['ldap'][1]['ldap_port'] = 'port';
$tlCfg->authentication['ldap'][1]['ldap_version'] = '3';
$tlCfg->authentication['ldap'][1]['ldap_root_dn'] = 'root_dn';
$tlCfg->authentication['ldap'][1]['ldap_bind_dn'] = 'bind_dn';
$tlCfg->authentication['ldap'][1]['ldap_bind_passwd'] = 'password';
$tlCfg->authentication['ldap'][1]['ldap_tls'] = false;
$tlCfg->authentication['ldap'][1]['ldap_organization'] = ')';
$tlCfg->authentication['ldap'][1]['ldap_uid_field'] = 'sAMAccountName';
$tlCfg->authentication['ldap'][1]['ldap_firstname_field'] = 'givenName';
$tlCfg->authentication['ldap'][1]['ldap_surname_field'] = 'sn';
$tlCfg->authentication['ldap'][1]['ldap_email_field'] = 'mail';

$tlCfg->authentication['ldap'][2]['ldap_server'] = 'ip2';
$tlCfg->authentication['ldap'][2]['ldap_port'] = 'port2';
$tlCfg->authentication['ldap'][2]['ldap_version'] = '3';
$tlCfg->authentication['ldap'][2]['ldap_root_dn'] = 'root_dn2';
$tlCfg->authentication['ldap'][2]['ldap_bind_dn'] = 'bind_dn2';
$tlCfg->authentication['ldap'][2]['ldap_bind_passwd'] = 'password';
$tlCfg->authentication['ldap'][2]['ldap_tls'] = false;
$tlCfg->authentication['ldap'][2]['ldap_organization'] = '';
$tlCfg->authentication['ldap'][2]['ldap_uid_field'] = 'uid';
$tlCfg->authentication['ldap'][2]['ldap_firstname_field'] = 'givenName';
$tlCfg->authentication['ldap'][2]['ldap_surname_field'] = 'sn';
$tlCfg->authentication['ldap'][2]['ldap_email_field'] = 'mail';

- Issue History
Date Modified Username Field Change
2020-02-18 13:54 adam122 New Issue
2020-02-18 13:58 adam122 Note Added: 0029490
2020-02-19 10:08 adam122 Note Added: 0029491



Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker