ldapauth-fork InvalidCredentialsError

前端 未结 1 1452
渐次进展
渐次进展 2020-12-21 23:20

I am trying to authenticate user against LDAP by using ldapauth-fork. I am having a problem with LDAP Admin account, while I know that it is right and works fine with LDAP b

相关标签:
1条回答
  • 2020-12-22 00:08

    Try using the activedirectory2 library over npm, I tried with ldapauth-form but could get a successful result

    It has a number of functions to get work done such as

    • authenticate
    • findUser

    Config code

    const AD = require('activedirectory2').promiseWrapper;
    const config = { url: 'ldap://dc.domain.com',
               baseDN: 'dc=domain,dc=com',
               username: 'username@domain.com',
               password: 'password' }
    const ad = new AD(config);
    

    for #authenticate

    var ad = new ActiveDirectory(config);
    var username = 'john.smith@domain.com';
    var password = 'password';
    
    ad.authenticate(username, password, function(err, auth) {
     if (err) {
       console.log('ERROR: '+JSON.stringify(err));
       return;
     }
    
    if (auth) {
     console.log('Authenticated!');
    }
    else {
     console.log('Authentication failed!');
    }
    });
    

    similarly for #finduser

    // Any of the following username types can be searched on
    var sAMAccountName = 'username';
    var userPrincipalName = 'username@domain.com';
    var dn = 'CN=Smith\\, John,OU=Users,DC=domain,DC=com';
    
    // Find user by a sAMAccountName
    var ad = new ActiveDirectory(config);
    ad.findUser(sAMAccountName, function(err, user) {
    if (err) {
     console.log('ERROR: ' +JSON.stringify(err));
     return;
    }
    
    if (! user) console.log('User: ' + sAMAccountName + ' not found.');
     else console.log(JSON.stringify(user));
    });
    
    0 讨论(0)
提交回复
热议问题