Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Non-integrated authentication" example / integration not working #52

Open
Mika83AC opened this issue May 12, 2017 · 5 comments
Open

"Non-integrated authentication" example / integration not working #52

Mika83AC opened this issue May 12, 2017 · 5 comments

Comments

@Mika83AC
Copy link

Mika83AC commented May 12, 2017

Hello everyone,

I'm trying to get the non-integrated authentication example to work, but I'm still failing.

So i tried some different approaches and found https://www.npmjs.com/package/activedirectory which is working fine for me. Here is the relevant snippet from my activedirectory implementation:

router.post('/', function (req, res) {
   console.log('received login request');

   var ad = new ActiveDirectory({
      url: 'ldap://xxx..xom',
      baseDN: 'dc=xxx,dc=com',
      username: req.body.username_reader + '@xxx.com', // user allowed to read the AD
      password: req.body.password_reader
   });

   ad.authenticate(req.body.username_login + '@xxx.com', // user to login in
			req.body.password_login, 
			function(err, isAuthenticated) {
      if(err) throw err;
      if(isAuthenticated) {
         console.log('Authenticated!');
      } else {
         console.log('Failed to authenticate');
      }
   });
});

This works fine and the username_login user gets authenticated.

Now I'm trying the "same" with passport-windowsauth and I'm failing. There returns no error, but also nothing else ever happens. The app gets lost in the passport.use and function(profile, done) never gets called:

router.post('/', function (req, res) {
   console.log('received login request');

   passport.use(new WindowsStrategy({
      ldap: {
         url: 'ldap://xxx.com/dc=xxx,dc=com',
         base: 'dc=xxx,dc=com',
         bindDN: req.body.username_reader + '@xxx.com',
         bindCredentials: req.body.password_reader
      },
      integrated: false
   }, function(profile, done){
      console.log('Authenticated!');
   }));
});

Where is my mistake, I'm stuck figuring it out on my own ...

Regards,
Michael

@cjmyles
Copy link

cjmyles commented May 25, 2017

This works for me:

passport.use(new WindowsStrategy({
  ldap: {
    url: 'ldap://xxx.com',
    base: 'DC=xxx,DC=com',
    bindDN: 'user@domain'
    bindCredentials: 'password'
  }
}, function(profile, done){
  console.log('Authenticated!');
}));

@Mika83AC
Copy link
Author

As it is working for you, there seems to be a different implementation for accessing the AD than for example "activedirectory" is using, which is working for me.

Which library is passport-windowsauth using for accessing the AD?

@cjmyles
Copy link

cjmyles commented May 29, 2017

Just one thing worth trying @Mika83AC - try removing the integrated: false line and see what happens. I'm sure this was causing issues for me too.

@Mika83AC
Copy link
Author

Hm... makes no difference for me. The AD request runs forever, no timeout, no error, the callback of new WindowsStrategy() gets never called.

As passport-windowsauth is using ldapjs as well as activedirectory, it has to be an issue inside the passport-windowsauth implementation I guess. Both use the same LDAP lib, but the outcome is different.

@AdrianRodriguezLlave
Copy link

LDAP use distinguishedName for authentication. The BindDN must be distinguisedName.
ActiveDirectory use sAMAccountName for authentication.

@cjmyles maybe this example works because the server allow anonymous authentication.

I've been several days trying to understand how LDAP works for auth and i did not find a way to direct authetication with sAMAccountName. There is way if you find the distinguisedName with a search but you need to authenticate first with a Service Account (an account that you create to read values). So you need to auth 2 times, first with service account, find the DN, then auth with this DN and passowrd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants