Closed skocdopolet closed 1 year ago
I cannot recreate in the latest version (v10). A lot was changed with escaping and sanitization it that version though.
I have upgraded my GLPI installation to version 10.0.0. The behavior is the same. Now the page display this warning
PHP Warning (2): ldap_search(): Search: Invalid DN syntax in src/AuthLDAP.php at line 1867
Did you remove the extra backslash? This base DN should work and remain unchanged after saving:
OU=Customer\, s.r.o., DC=example, DC=com
I have this settings When I push the Search (Hledat) button, I got no results and the form changes to this:
When I remove extra backslash and send the form again, I got same results - extra backslash is added and no results...
Hello! I have same problem with & in OU Example OU=Customer&Groups,DC=example,DC=com
Could anyone help with this issue?
Hello @skocdopolet
To partially solve this isue, you may add the following line in inc/authldap.class.php file in the searchForUsers() function:
$values['basedn'] = Toolbox::stripslashes_deep($values['basedn']);
Here:
This will partially fix the issue: it will strip the double slash, and the DN will be OK for the search, but it will be NOK at next display of the form.
Thank you, Regards, Tomolimo
Hello @skocdopolet
A better solution would be to keep inc/authldap.class.php
as it was and to modify front/ldap_import.php
file
Replace content of front/ldap_import.php
by following code:
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2021 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
if (!defined('GLPI_ROOT')) {
include ('../inc/includes.php');
}
Session::checkRight("user", User::IMPORTEXTAUTHUSERS);
// Need REQUEST to manage initial values and posted ones
if (isset($_REQUEST['basedn'])) {
$_REQUEST['basedn'] = Toolbox::stripslashes_deep($_REQUEST['basedn']);
}
if (isset($_REQUEST['ldap_filter'])) {
$_REQUEST['ldap_filter'] = Toolbox::stripslashes_deep($_REQUEST['ldap_filter']);
}
AuthLDAP::manageValuesInSession($_REQUEST);
if (isset($_SESSION['ldap_import']['_in_modal']) && $_SESSION['ldap_import']['_in_modal']) {
$_REQUEST['_in_modal'] = 1;
}
Html::header(__('LDAP directory link'), $_SERVER['PHP_SELF'], "admin", "user", "ldap");
if (isset($_REQUEST['start'])) {
$_SESSION['ldap_import']['start'] = $_REQUEST['start'];
}
if (isset($_REQUEST['order'])) {
$_SESSION['ldap_import']['order'] = $_REQUEST['order'];
}
if ($_SESSION['ldap_import']['action'] == 'show') {
$authldap = new AuthLDAP();
$authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
AuthLDAP::showUserImportForm($authldap);
if (isset($_SESSION['ldap_import']['authldaps_id'])
&& ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE)
&& (isset($_REQUEST['search']) || isset($_REQUEST['start']) || isset($_REQUEST['glpilist_limit']))) {
echo "<br />";
AuthLDAP::searchUser($authldap);
}
}
Html::footer();
Thank you Regards, Tomolimo
Hello @tomolimo,
Today, I upgraded GLPI to latest version 10.0.0.3. I can confirm that Your code is working!
What are the next steps?
Thank you! Regards Tomas
@tomolimo
Can you check if this has been fixed in GLPI 10.0.5? If problem persist, could you open a pull request?
Hi @skocdopolet @StackAls
Could you test patch proposed in #11317?
Code of Conduct
Is there an existing issue for this?
Version
9.5.7
Bug description
Hi,
I am trying to make batch import users from LDAP directory in Expert mode. Our customer has Active Directory on Microsoft Windows Server. All required users to import are stored in Organization Unit which name contains a comma character (i.e.: Customer, s.r.o.). Field BaseDN should contains
OU=Customer\, s.r.o., DC=example, DC=com
When I click to Search backup, no results are found, but in BaseDN field, there are two backslashes
OU=Customer\\, s.r.o., DC=example, DC=com
I try this variants, but any without success:
OU="Customer, s.r.o.", DC=example, DC=com
=>OU=\
OU='Customer, s.r.o.', DC=example, DC=com
=>OU=\'Customer, s.r.o.\', DC=example, DC=com
Relevant log output
No response
Page URL
https://helpdesk..../front/ldap.import.php
Steps To reproduce
Your GLPI setup information
Anything else?
No response