auth0 / passport-windowsauth

Windows Authentication strategy for Passport.js
MIT License
178 stars 54 forks source link

profile is null on non-integrated node js application #54

Open mnavidad opened 6 years ago

mnavidad commented 6 years ago

Hi We have a node js application using passport-windowsauth for ldap, the code is set up to also use a form. here is the code nodeappcodepng

js code jscodenode

when we run the application the profile is null and I do not know why, the application is running on express server however we use IIS as a passthrough using ARR. I'm looking to see if someone can shed a light to this issue or point me in the right direction to see why this is not working

Thank you so much!

newmanw commented 5 years ago

Seeing the same thing.

Looks like this has been sitting for a while, any ideas?

marce2509 commented 5 years ago

I have the same problem. profile is null

jg76379 commented 5 years ago

I had the same issue and I found that it was because the default ldap query was not correct for our ldap configuration.

However, The strategy accepts a search_query argument (although this does not seem to be documented anywhere):

The passport-windowsauth LdapLookup.js shows the following:

this._search_query = options.search_query || '(&(objectclass=user)(|(sAMAccountName={0})(UserPrincipalName={0})))';

To get the strategy to work with our ldap I had to modify the query to search for "cn" instead of "UserPrincipalName". This is how you pass in the argument:

var passport = require("passport");
var WindowsStrategy = require("passport-windowsauth");
// ...
// Init passport strategy
passport.use(new WindowsStrategy({
    ldap: {
        url: ldapUrl,
        base: ldapBase,
        bindDN: ldapBindUN,
        bindCredentials: ldapBindPW,
        search_query: "(&(objectclass=user)(|(sAMAccountName={0})(cn={0})))"
    },
    integrated: false
}
mnavidad commented 5 years ago

thank you!