JackAdams / meteor-accounts-ldap

Authentication against an LDAP server in Meteor
MIT License
21 stars 12 forks source link

Failed to make it work with simple Active Directory #19

Closed aessig closed 7 years ago

aessig commented 7 years ago

Hi, Great package, I tried to make it work with this simple public directory for hours without success. http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

Any idea how to configure the settings to make it work. I have constantly the error "invalid DN"

Here is my config:

LDAP.generateSettings = function (request) {
  return {
    "serverDn": "dc=example,dc=com",
    "serverUrl": "ldap://ldap.forumsys.com",
    "whiteListedFields": [ "displayName", "givenName", "department", "employeeNumber", "mail", "title", "address", "phone", "memberOf"],
    "autopublishFields": [ "displayName", "department", "mail", "title", "address", "phone"]
  };
}

and then I used "einstein" and "password" as credentials.

Here is my output:

I20170206-17:27:17.177(1)? Trying to bind einstein@example.com...
I20170206-17:27:17.361(1)? Callback from binding LDAP:
I20170206-17:27:17.362(1)? {"dn":"","code":34,"name":"InvalidDnSyntaxError","message":"invalid DN"}
I20170206-17:27:17.362(1)? LDAP bind failed with error
I20170206-17:27:17.363(1)? {"dn":"","code":34,"name":"InvalidDnSyntaxError","message":"invalid DN"}
aessig commented 7 years ago

@JackAdams Any idea what could be the problem ?

JackAdams commented 7 years ago

Here's an example that's working for me:

{
  "serverDn": "OU=SOME_OU,DC=example,DC=com",
  "serverUrl": "ldap://ldap.example.com:389",
  "whiteListedFields": [
    "displayName"
  ]
}

The only differences I can see are:

  1. capitals for DN (probably not the problem)
  2. inclusion of a port number for the serverUrl (more likely to be the issue)

I also noticed that your serverDn and serverUrl have a mismatch. You have:

  "serverDn": "dc=example,dc=com",
  "serverUrl": "ldap://ldap.forumsys.com",

it should be:

  "serverDn": "dc=forumsys,dc=com",
  "serverUrl": "ldap://ldap.forumsys.com:389",

(Although this is probably just because you forgot to change the forumsys to example in your sample code. ;-))

aessig commented 7 years ago

Thank you very much @JackAdams. Unfortunately, it doesn't work. The server is "dc=example,dc=com" has you can see on the image I have linked with.

capture d ecran 2017-02-08 a 11 47 06

However they give bind DN and bind Password, is it something I should provide in some way ?

capture d ecran 2017-02-08 a 11 49 20
JackAdams commented 7 years ago

Have you tried both these?

  "serverDn": "dc=example,dc=com",
  "serverUrl": "ldap://ldap.forumsys.com:389",

and

  "serverDn": "dc=forumsys,dc=com",
  "serverUrl": "ldap://ldap.forumsys.com:389",

Note the inclusion of the port number.

aessig commented 7 years ago

Unfortunately it doesn't work with this directory. But I make it work with an other active directory by adding:

LDAP.searchField='userPrincipalName';
LDAP.searchValueType='userPrincipalName';

So it's good for now. Thank you for your help.