Nodejs actice 目录身份验证需要很长时间才能失败

时间:2021-03-15 18:50:19

标签: node.js

我正在使用这个 node-activedirectory 包来使用 Nodejs 执行活动目录身份验证。我只使用库来检查用户是否存在于活动目录中。当存在具有提供的用户名和密码的用户时,该库工作得非常好。这是我的设置

const activeDirectory = require('activedirectory');

//Setup active directory configuration

let activeDirectoryConfig = {
    url: keys.activeDirectory.url,
    baseDN: keys.activeDirectory.baseDN,
    timeout: 500,
    idleTimeout: 500,
    logging: {
        name: 'ActiveDirectory',
        streams: [
          { level: 'error',
            stream: process.stdout }
        ]
      }
}

let ad = new activeDirectory(activeDirectoryConfig);


ad.authenticate(`${name}@mycomp.com`, password, async function(err, auth) {
                            //Commeting this error out during development because this error fires when connection to ad does not fire which is always the case in development
                            if (err) {
                              console.log('ERROR: '+JSON.stringify(err));
                              return done(null, false, req.flash('invalidAuth', 'No account was found associated with this username'));
                              
                            }
                               
                            if (auth) {
                               //user found do something

                            }

我面临的问题是,如果我提供活动目录中不存在的用户名和密码,则需要将近 15-20 秒才能给出一条错误消息:

<块引用>

错误: {"errno":"ETIMEDOUT","code":"ETIMEDOUT","syscall":"connect","address":"35.208.54.69","port":389}

即使我将超时设置为低至 500 毫秒,就像您在配置中看到的那样,它仍然需要很多时间。我不确定我这样做是否正确。我在网上找不到很多可以帮助我解决这个问题的内容

0 个答案:

没有答案