snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

LDAP Logins not working

Open Zorlin opened this issue 8 years ago • 18 comments

Expected Behavior (or desired behavior if a feature request)

Ability to log into users imported from LDAP.


Actual Behavior

The users and emails etc all synchronize correctly, but you cannot log into any of the imported accounts (after enabling them).

In the LDAP admin panel, when running "Test LDAP Sync", this comes up: Connection to LDAP server established!

However, just below it, running "Test LDAP Login", I get the message "Login Failed. barntzen did not successfully bind to LDAP."

Additionally, when attempting to login to a valid LDAP user, this appears in the Laravel log: production.ERROR: There was an error authenticating the LDAP user: Could not find user in LDAP directory


Please confirm you have done the following before posting your bug report:


Provide answers to these questions:

  • Is this a fresh install or an upgrade? Fresh
  • Version of Snipe-IT you're running - v4.1.11-pre - build 3307 (master)
  • Version of PHP you're running - php5.6-fpm (5.6.33-3+ubuntu16.04.1+deb.sury.org+1)
  • Version of MySQL/MariaDB you're running - mysqld Ver 5.7.21-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))
  • What OS and web server you're running Snipe-IT on - Ubuntu 16.04 + nginx version: nginx/1.10.3
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - Git
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error - http://foo.bar.com/admin/ldap
  • If a stacktrace is provided in the error, include that too. - N/A
  • Any errors that appear in your browser's error console. - None
  • Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo. - N/A
  • Include any additional information you can find in storage/logs and your webserver's logs. - Included above
  • Include what you've done so far in the installation, and if you got any error messages along the way. - Install completed, added a bunch of assets
  • Indicate whether or not you've manually edited any data directly in the database - No

My LDAP Settings

LDAP Integration: Yes, checked and enabled Active Directory: No, unchecked LDAP Password Sync: Yes, checked and enabled

Active Directory domain: bar.com.au LDAP Server: ldaps://foo.bar.com.au Use TLS: No, unchecked LDAP SSL certificate validation - Allow invalid SSL Certificate: Yes, checked and enabled

LDAP Bind Username: cn=bind,ou=services,dc=bar,dc=com,dc=au LDAP Bind Password: Base Bind DN: ou=users,dc=bar,dc=com,dc=au

LDAP Filter: &(objectClass=posixAccount) Username Field: uid Last Name: sn LDAP First Name: givenname

LDAP Authentication query: uid= LDAP Version: 3 LDAP Active Flag: null LDAP Employee Number: null LDAP Email: mail

Zorlin avatar Feb 07 '18 09:02 Zorlin

I have something weird - Distinguished Name: cn=Benjamin Arntzen,ou=users,dc=bar,dc=com,dc=au

Maybe it's finding cn, not uid? or something

I've tried the following as LDAP Authentication query:

  • uid
  • uid=
  • uid=uid
  • cn
  • cn=
  • cn=cn

Zorlin avatar Feb 07 '18 09:02 Zorlin

I tried setting "Username Field" to cn and LDAP Authentication Query to "cn=" and that did not help (using either full name "Benjamin Arntzen" or username "barntzen")

Zorlin avatar Feb 07 '18 09:02 Zorlin

WTF.

I tried the CN trick again - set "Username Field" to cn and LDAP Authentication Query to "cn=", then tried to log in as "Benjamin Arntzen" and it worked. I can authenticate cleanly and it seems to work.

This is unfortunately not a full solution - I need to be able to auth using username. However it does show that LDAP at least sort-of-works.

Zorlin avatar Feb 08 '18 10:02 Zorlin

I had a similar issue to this when I was setting it up. You need to check the ' This is an Active Directory server' box. It's kind of confusing because it doesn't mean that the current server Snipe-IT is on is an Active Directory server. The checkbox is asking if the server you are connecting to is an Active Directory server vs an LDAP server. Confusing but give it a try. Also, I have LDAP Authentication query set to 'sAMAccountName=', not sure if you'll need to change that too.

blackrandom avatar Feb 10 '18 05:02 blackrandom

I'm using OpenLDAP, not Active Directory.

Zorlin avatar Feb 10 '18 15:02 Zorlin

@blackrandom this resolved the issue for me, thank you.

stiefler1 avatar Feb 14 '18 14:02 stiefler1

@Zorlin Hi,

I have tried you CN trick but it doesn't work for me :/ I'm using OpenLDAP.

LDAP Filter -> &(objectClass=posixAccount) Username Field -> cn LDAP Authentication query -> cn=

Connection test is successful Test LDAP Sync -> Connection to LDAP server established!

But the second test has failed Test LDAP Login -> ldap_search(): Search: No such object Pretty weird error message :) If I'm using a incorrect password -> Login Failed. Louis PARROUY did not successfully bind to LDAP.

mink-adao-duy avatar Feb 23 '18 18:02 mink-adao-duy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

stale[bot] avatar May 05 '18 03:05 stale[bot]

I tried the CN trick again - set "Username Field" to cn and LDAP Authentication Query to "cn=", then tried to log in as "Benjamin Arntzen" and it worked. I can authenticate cleanly and it seems to work.

This is unfortunately not a full solution - I need to be able to auth using username. However it does show that LDAP at least sort-of-works.

This is my first installation, using 4.6.15. I'm running into the same exact problem: I can't use 'uid'/'uid=' as username/auth query for logging in, while using 'cn'/'cn=' works. Similarly, this is suboptimal, as I can't expect our users to type in their full names to log in.

We're using openLDAP as our LDAP service.

dominikborkowski avatar Apr 09 '19 03:04 dominikborkowski

I'm having a similar problem using OpenLDAP.

For some reason, I'm binding, but it's not returning correctly.

Is there any kind of debug logging I can enable for SnipeIT's LDAP features?

Paralda avatar Feb 20 '20 18:02 Paralda

I'm also trying to figure out how to debug the LDAP so that I can figure out what's wrong, as I have this exact error. Enabling debug in .env doesn't seem to do it, and the logs are not helpful.

tareko avatar May 30 '20 10:05 tareko

Not sure if this is related but we too have OpenLDAP. I managed to get it working after few hours debugging the code. I am shouting at the screen very loudly right now.

APP_LOG_LEVEL=debug is a must have setting for this.

Problem 1: BaseDN

I am not using LDAP sync. I want only to authenticate the user via LDAP and create the local account record JIT style during first login.

Normal LDAP access usually looks something like this:

  1. Bind to directory using service account
  2. Find user object in BaseDN subtree
  3. Bind using the DN of that object
  4. Do anything else

SnipeIT does this:

  1. Binds to the directory using Username Field + = + username + Base Bind DN

    For example: If you have user uid=user,ou=abc,dc=xyz and you only specify basedn = dc=xyz it won't authenticate -> You have to specify the exact parent object where your user are stored. Forget searching the LDAP database from the top.

  2. Searches for the the object using the filter: LDAP Authentication query + username

Problem 2: Attributes must be in lowercase

LDAP attribute names are converted to the lowercase for some reason! Try setting givenName (which is correct attribute name) as your LDAP First Name. It won't find it. You have to set givenname as your LDAP First Name.

Yea docs says it but it could explain why because this behavior is kind of unique:

In most cases, all attribute values you enter should be all lowercase

MichalMMac avatar Aug 04 '20 16:08 MichalMMac

@MichalMMac how were you able to get this working? I am running into the same issue where the only way to get to the LDAP search is to "login" with "First Last" as opposed to username.

RustyBower avatar Aug 20 '20 20:08 RustyBower

Please try the following settings. I hope this help you guys.

ldapsnipeitsettings

aice09 avatar Jul 29 '22 13:07 aice09

I tried the all the above methods,but didn't work

ecswai201 avatar Nov 30 '22 07:11 ecswai201

Is there anybody found the solutions?

ecswai201 avatar Nov 30 '22 07:11 ecswai201

I am still struggling with this. I use zimbra, and I can login to seafile, nextcloud just fine. But for this one it's really difficult, ldapt test works, but users won't bind.

I am trying to use email as login. this is my config

image

Any pointers?

andres-asm avatar Jan 10 '23 17:01 andres-asm

Actually I managed to make it work, but only with uid... I want to use emails

image

Another issue I have is that I only want to allow login for (zimbraIsAdminAccount=TRUE), again, this works well as a filter, the test ldap connection works fine, but it won't allow login, even if I add it to what is currently working.

andres-asm avatar Jan 10 '23 18:01 andres-asm