Downgrade to Version 3 - LDAP not working for me in 4.0.15
Hi Snipe, is it possible to downgrade back to Version 3.x? Since the upgrade to 4.0.x (currently at 4.0.11) the LDAP is not working anymore (see here: https://github.com/snipe/snipe-it/issues/4050) and because we are using it in our live-environment I need to know if there is a possibility for me to easy downgrade back to Version 3 without loosing all data..
I love the new version but the LDAP is nessecary in a AD network with more than 1.000 users.
Best
Try upgrading to latest - we've made some changes to LDAP since then.
also the upgrade to 4.0.13 didnt fix the issue :(
@pvhkai can you be more specific with "LDAP is not working"? We've tested this pretty thoroughly with v4.0.13, so if it's not working for you, we want to know what's happening what your logs say, etc.
@snipe
- As I wrote in https://github.com/snipe/snipe-it/issues/4050 -
I get the following error:
**LDAP Sync Test:** Connection to LDAP server established!
**Test LDAP Login:** Login Failed. corp\adminuser did not successfully bind to LDAP.
And I use exactly the same username and password.. :(
If I now make an sync (not neccecary if I do this by script or webpage) the script syncs 10-12 random users (from mixed OUs) and I dont get any error message. I tested with two locations and checked twice if the LDAP settings are correct! Funfact the same 10-12 random users will also displayed if the LDAP setting in the sync location is empty...
What Logs do you need?
The same logs we alway need. Anything from strorage/logs/laravel.log that related to your LDAP process.
It doesn't sound like LDAP isn't working though - the fact that you're getting the same random users means 1) LDAP is working and 2) there is something unique about these users that makes them always be returned.
What value do you have for your LDAP Active Flag in your LDAP settings?
(Make sure debug is set to true in your .env when you're generating those logs, so we get verbose output)
Thats what I made (in correct order):
- Start Debug Mode
- Sync Location Moscow Russia (ID 7) - Location has nothing set in the LDAP section of the location --> Result (Random Users)
- Sync Location München Showroom (ID 3) --> Result (Random Users)
- Pressed LDAP Sync Test: Connection to LDAP server established!
- Pressed Test LDAP Login: Login Failed. corp\user did not successfully bind to LDAP.
Logfile
[2017-10-18 09:14:52] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-18 09:14:59] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-18 09:50:16] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-19 12:26:38] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-19 12:26:38] production.DEBUG: Location ID 7 passed
[2017-10-19 12:26:38] production.DEBUG: Importing to Moscow Russia (7)
[2017-10-19 12:27:02] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-19 12:27:02] production.DEBUG: Location ID 3 passed
[2017-10-19 12:27:02] production.DEBUG: Importing to München Showroom (3)
[2017-10-19 12:28:48] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 12:28:48] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 12:29:04] production.DEBUG: Preparing to test LDAP login
[2017-10-19 12:29:04] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 12:29:04] production.DEBUG: Attempting to login using distinguished name:corp\[email protected]
LDAP Settings
LDAP Integration: [x] LDAP enabled Active Directory: [x] This is an Active Directory server LDAP Password Sync: [x] Yes Active Directory domain: company.com LDAP Server : ldap://company.com Use TLS: [ ] LDAP SSL certificate validation: [ ] Allow invalid SSL Certificate LDAP Bind Username : company.com\adminuser LDAP Bind Password: ******* Base Bind DN: OU=ABC,DC=company,DC=local LDAP Filter: &(cn=*) Username Field: sAMAccountName Last Name: sn LDAP First Name: givenname LDAP Authentication query: sAMAccountName LDAP Version: 3 LDAP Active Flag: LDAP Employee Number: LDAP Email: mail
LDAP Search Flag of Location "Munich Showroom"
OU=User Accounts,OU=MUN01,OU=Europe,DC=CORP,DC=COM
Comment
In the Logfile you see that the User is corp\[email protected] but I did not enter that - I entered corp\user (without the @corp.com).
I believe Username Field: sAMAccountName should be Username Field: samaccountname, per the LDAP configuration documentation.
In the Logfile you see that the User is corp\[email protected] but I did not enter that - I entered corp\user (without the @corp.com).
I assume you mean company.com, as it relates to your examples above?
The code that controls the UDN is:
$userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn;
if ($settings->is_ad =='1') {
// Check if they are using the userprincipalname for the username field.
// If they are, we can skip building the UPN to authenticate against AD
if ($ldap_username_field=='userprincipalname') {
$userDn = $username;
} else {
// In case they haven't added an AD domain
$userDn = ($settings->ad_domain != '') ? $username.'@'.$settings->ad_domain : $username.'@'.$settings->email_domain;
}
}
I believe LDAP Authentication query: sAMAccountName should be LDAP Authentication query: sAMAccountName= as well
also you shouldn't be providing corp\ with your username as @snipe pointed out the code adds @company.com which should be your AD domain
Thank you! @madd15 & @snipe
I changed the "LDAP Authentication query:" to sAMAccountName= and the Username from corp\adminuser to adminuser. But that didnt change anything...
Did you change Username Field: sAMAccountName to Username Field: samaccountname? Additionally, what are your logs saying now with these new settings?
I changed
"LDAP Username Field:" to samaccountname
"LDAP Authentication query:" to sAMAccountName=
"Username" from corp\adminuser to adminuser
But that didnt change anything...
Logfile
[2017-10-19 14:29:50] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:29:50] production.DEBUG: Attempting to login using distinguished name:[email protected]
@pvhkai what else is in the logs though?
thats what under the lines I send. Shall I send you the whole file by mail?
--> As you see I tried several times..
Logfile
[2017-10-18 09:14:52] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-18 09:14:59] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-18 09:50:16] production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory
[2017-10-19 12:26:38] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-19 12:26:38] production.DEBUG: Location ID 7 passed
[2017-10-19 12:26:38] production.DEBUG: Importing to Moscow Russia (7)
[2017-10-19 12:27:02] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-19 12:27:02] production.DEBUG: Location ID 3 passed
[2017-10-19 12:27:02] production.DEBUG: Importing to München Showroom (3)
[2017-10-19 12:28:48] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 12:28:48] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 12:29:04] production.DEBUG: Preparing to test LDAP login
[2017-10-19 12:29:04] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 12:29:04] production.DEBUG: Attempting to login using distinguished name:corp\[email protected]
[2017-10-19 13:49:26] production.DEBUG: Preparing to test LDAP login
[2017-10-19 13:49:26] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 13:49:26] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 13:49:37] production.DEBUG: Preparing to test LDAP login
[2017-10-19 13:49:37] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 13:49:37] production.DEBUG: Attempting to login using distinguished name:corp\[email protected]
[2017-10-19 13:50:15] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 13:50:15] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 13:50:20] production.DEBUG: Preparing to test LDAP login
[2017-10-19 13:50:20] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 13:50:20] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 13:55:48] production.DEBUG: Preparing to test LDAP login
[2017-10-19 13:55:48] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 13:55:48] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 13:59:50] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 13:59:50] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 13:59:59] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 13:59:59] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:00:06] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:00:06] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:00:06] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:00:18] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:00:18] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:00:18] production.DEBUG: Attempting to login using distinguished name:[email protected]@corp.com
[2017-10-19 14:00:28] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:00:28] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:01:20] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:01:20] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:01:20] production.DEBUG: Attempting to login using distinguished name:corp\[email protected]
[2017-10-19 14:01:26] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:01:26] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:01:26] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:01:33] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:01:33] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:01:33] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:03:52] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:03:52] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:04:15] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:04:15] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:04:15] production.DEBUG: Bind failed
[2017-10-19 14:04:26] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:04:26] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:04:26] production.DEBUG: Bind failed
[2017-10-19 14:04:42] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:04:42] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:08:01] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:08:01] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:08:01] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:08:21] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:08:21] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:08:21] production.DEBUG: Attempting to login using distinguished name:corp\[email protected]
[2017-10-19 14:29:21] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:29:21] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:29:32] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:29:32] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:29:32] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:29:40] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:29:40] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-19 14:29:50] production.DEBUG: Preparing to test LDAP login
[2017-10-19 14:29:50] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-19 14:29:50] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-19 14:50:27] production.DEBUG: Preparing to test LDAP connection
[2017-10-19 14:50:27] production.DEBUG: attempting to bind to LDAP for LDAP test
The user you use to test the login from the config panel must be in the group you specify in the "base DN" field.
I have been configuring this a couple hours ago (i updated to the latest version this morning) and everything seems to work fine now.
Also when you change anything in the config you need to first save, and then go in again and test it, if you change anything and test before saving it doesnt work.
Hi @korio77 - Hi @snipe , thanks a lot for your help - Putting the Admin Ou as Bind OU was the solution for the error that the "Test LDAP Login: Login Failed. corp\adminuser did not successfully bind to LDAP."
[2017-10-20 08:17:54] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-20 08:17:54] production.DEBUG: It worked! adminuser1 successfully binded to LDAP.
[2017-10-20 08:18:12] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-20 08:18:12] production.DEBUG: Location ID 1 passed
[2017-10-20 08:18:12] production.DEBUG: Importing to Duesseldorf Headoffice (1)
[2017-10-20 08:18:50] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-20 08:18:50] production.DEBUG: Location ID 3 passed
[2017-10-20 08:18:50] production.DEBUG: Importing to München Showroom (3)
[2017-10-20 08:19:24] production.DEBUG: Preparing to test LDAP connection
[2017-10-20 08:19:24] production.DEBUG: attempting to bind to LDAP for LDAP test
[2017-10-20 08:19:35] production.DEBUG: Preparing to test LDAP login
[2017-10-20 08:19:35] production.DEBUG: Attempting to bind to LDAP for LDAP test
[2017-10-20 08:19:35] production.DEBUG: Attempting to login using distinguished name:[email protected]
[2017-10-20 08:19:35] production.DEBUG: It worked! adminuser1 successfully binded to LDAP.
[2017-10-20 08:27:16] production.DEBUG: Some locations have special OUs set. Locations will be automatically set for users in those OUs.
[2017-10-20 08:27:16] production.DEBUG: Location ID 1 passed
[2017-10-20 08:27:16] production.DEBUG: Importing to Duesseldorf Showroom (1)
There is always a BUT
But the sync doesnt sync what it shoud do - I checked all OUs in the locations again and made a copy+past from the AD. But it throws out random wrong users. And always the same users not necessary which location I sync. I there a cache/ config/ thing I can reset or any other idea?