Improve latency of findUsers query made by node js activedirectory module












0















I am expriencing high latency when fetching users from active directory in nodejs.



I am using the node library from npm 'activedirectry'. https://www.npmjs.com/package/activedirectory



The amount of users is relatively not big, About 1000 users...



The time of the query takes between 2 to 4 seconds.



The default query provided by the function findUsers of the 'activedirectory' library is (&(|(objectClass=user)(objectClass=person))(!(objectClass=computer))(!(objectClass=group))).



I added an additional filter on the sAMAccountName field. sAMAccountName=*somePartOfName*



In any case, with or without my addition the query time is still slow.



I don't have full configuration of the active directory server,
But it seems like other platforms on the same network work faster with the active directory but they work with other frameworks, in java and .NET.



What could be the reason for this high latency?



Thanks



// ad is configured only with user, password, base dn and url

function findUsers(partOfsAMAccountName) {
const additionalQuery = `sAMAccountName=*${partOfsAMAccountName}*`;

return new Promise(resolve => {
ad.findUsers(additionalQuery, false, (error, users) => {
if(error) {
console.error('%j', error);
}

resolve(users || );
})
}
}


What I am tring to do is to create an autocomplete mechanism based on the usernames of the active directory.



On the same network we have bitbucket server connected to the same active directory server. It seems like from the bitbucket client the autocomplete is much faster. about 1 sec from the client side.



I had already searched for the open souce of bitbucket but didn't find any.










share|improve this question





























    0















    I am expriencing high latency when fetching users from active directory in nodejs.



    I am using the node library from npm 'activedirectry'. https://www.npmjs.com/package/activedirectory



    The amount of users is relatively not big, About 1000 users...



    The time of the query takes between 2 to 4 seconds.



    The default query provided by the function findUsers of the 'activedirectory' library is (&(|(objectClass=user)(objectClass=person))(!(objectClass=computer))(!(objectClass=group))).



    I added an additional filter on the sAMAccountName field. sAMAccountName=*somePartOfName*



    In any case, with or without my addition the query time is still slow.



    I don't have full configuration of the active directory server,
    But it seems like other platforms on the same network work faster with the active directory but they work with other frameworks, in java and .NET.



    What could be the reason for this high latency?



    Thanks



    // ad is configured only with user, password, base dn and url

    function findUsers(partOfsAMAccountName) {
    const additionalQuery = `sAMAccountName=*${partOfsAMAccountName}*`;

    return new Promise(resolve => {
    ad.findUsers(additionalQuery, false, (error, users) => {
    if(error) {
    console.error('%j', error);
    }

    resolve(users || );
    })
    }
    }


    What I am tring to do is to create an autocomplete mechanism based on the usernames of the active directory.



    On the same network we have bitbucket server connected to the same active directory server. It seems like from the bitbucket client the autocomplete is much faster. about 1 sec from the client side.



    I had already searched for the open souce of bitbucket but didn't find any.










    share|improve this question



























      0












      0








      0








      I am expriencing high latency when fetching users from active directory in nodejs.



      I am using the node library from npm 'activedirectry'. https://www.npmjs.com/package/activedirectory



      The amount of users is relatively not big, About 1000 users...



      The time of the query takes between 2 to 4 seconds.



      The default query provided by the function findUsers of the 'activedirectory' library is (&(|(objectClass=user)(objectClass=person))(!(objectClass=computer))(!(objectClass=group))).



      I added an additional filter on the sAMAccountName field. sAMAccountName=*somePartOfName*



      In any case, with or without my addition the query time is still slow.



      I don't have full configuration of the active directory server,
      But it seems like other platforms on the same network work faster with the active directory but they work with other frameworks, in java and .NET.



      What could be the reason for this high latency?



      Thanks



      // ad is configured only with user, password, base dn and url

      function findUsers(partOfsAMAccountName) {
      const additionalQuery = `sAMAccountName=*${partOfsAMAccountName}*`;

      return new Promise(resolve => {
      ad.findUsers(additionalQuery, false, (error, users) => {
      if(error) {
      console.error('%j', error);
      }

      resolve(users || );
      })
      }
      }


      What I am tring to do is to create an autocomplete mechanism based on the usernames of the active directory.



      On the same network we have bitbucket server connected to the same active directory server. It seems like from the bitbucket client the autocomplete is much faster. about 1 sec from the client side.



      I had already searched for the open souce of bitbucket but didn't find any.










      share|improve this question
















      I am expriencing high latency when fetching users from active directory in nodejs.



      I am using the node library from npm 'activedirectry'. https://www.npmjs.com/package/activedirectory



      The amount of users is relatively not big, About 1000 users...



      The time of the query takes between 2 to 4 seconds.



      The default query provided by the function findUsers of the 'activedirectory' library is (&(|(objectClass=user)(objectClass=person))(!(objectClass=computer))(!(objectClass=group))).



      I added an additional filter on the sAMAccountName field. sAMAccountName=*somePartOfName*



      In any case, with or without my addition the query time is still slow.



      I don't have full configuration of the active directory server,
      But it seems like other platforms on the same network work faster with the active directory but they work with other frameworks, in java and .NET.



      What could be the reason for this high latency?



      Thanks



      // ad is configured only with user, password, base dn and url

      function findUsers(partOfsAMAccountName) {
      const additionalQuery = `sAMAccountName=*${partOfsAMAccountName}*`;

      return new Promise(resolve => {
      ad.findUsers(additionalQuery, false, (error, users) => {
      if(error) {
      console.error('%j', error);
      }

      resolve(users || );
      })
      }
      }


      What I am tring to do is to create an autocomplete mechanism based on the usernames of the active directory.



      On the same network we have bitbucket server connected to the same active directory server. It seems like from the bitbucket client the autocomplete is much faster. about 1 sec from the client side.



      I had already searched for the open souce of bitbucket but didn't find any.







      node.js performance networking active-directory






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 20 at 15:18







      Ofek Ben Yaish

















      asked Jan 20 at 15:10









      Ofek Ben YaishOfek Ben Yaish

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I have no idea about node.js, and have never programmed in the same. But, from the question I feel that default query provided for findUsers() might be the culprit.




          As per Microsoft Docs, LDAP filter for
          (&(objectClass=user)(objectCategory=person))
          is sufficient for determining the users.




          In the official documentation for function findUsers(opts, callback), I can see the argument opts description about Optional parameters to extend or override functionality.



          So, I think you can override the LDAP filter query using the opts argument in findUsers function to keep the above advised LDAP filter, and additionally put your sAMAccountName condition in the search query. Please explore on how to override the opts argument, as I can't help you with that.



          I am hopeful that the result would be comparatively faster after doing the search this way.






          share|improve this answer



















          • 1





            Thank you, that is much faster.

            – Ofek Ben Yaish
            Jan 21 at 9:32











          • @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

            – Am_I_Helpful
            Jan 21 at 10:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277809%2fimprove-latency-of-findusers-query-made-by-node-js-activedirectory-module%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I have no idea about node.js, and have never programmed in the same. But, from the question I feel that default query provided for findUsers() might be the culprit.




          As per Microsoft Docs, LDAP filter for
          (&(objectClass=user)(objectCategory=person))
          is sufficient for determining the users.




          In the official documentation for function findUsers(opts, callback), I can see the argument opts description about Optional parameters to extend or override functionality.



          So, I think you can override the LDAP filter query using the opts argument in findUsers function to keep the above advised LDAP filter, and additionally put your sAMAccountName condition in the search query. Please explore on how to override the opts argument, as I can't help you with that.



          I am hopeful that the result would be comparatively faster after doing the search this way.






          share|improve this answer



















          • 1





            Thank you, that is much faster.

            – Ofek Ben Yaish
            Jan 21 at 9:32











          • @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

            – Am_I_Helpful
            Jan 21 at 10:14
















          0














          I have no idea about node.js, and have never programmed in the same. But, from the question I feel that default query provided for findUsers() might be the culprit.




          As per Microsoft Docs, LDAP filter for
          (&(objectClass=user)(objectCategory=person))
          is sufficient for determining the users.




          In the official documentation for function findUsers(opts, callback), I can see the argument opts description about Optional parameters to extend or override functionality.



          So, I think you can override the LDAP filter query using the opts argument in findUsers function to keep the above advised LDAP filter, and additionally put your sAMAccountName condition in the search query. Please explore on how to override the opts argument, as I can't help you with that.



          I am hopeful that the result would be comparatively faster after doing the search this way.






          share|improve this answer



















          • 1





            Thank you, that is much faster.

            – Ofek Ben Yaish
            Jan 21 at 9:32











          • @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

            – Am_I_Helpful
            Jan 21 at 10:14














          0












          0








          0







          I have no idea about node.js, and have never programmed in the same. But, from the question I feel that default query provided for findUsers() might be the culprit.




          As per Microsoft Docs, LDAP filter for
          (&(objectClass=user)(objectCategory=person))
          is sufficient for determining the users.




          In the official documentation for function findUsers(opts, callback), I can see the argument opts description about Optional parameters to extend or override functionality.



          So, I think you can override the LDAP filter query using the opts argument in findUsers function to keep the above advised LDAP filter, and additionally put your sAMAccountName condition in the search query. Please explore on how to override the opts argument, as I can't help you with that.



          I am hopeful that the result would be comparatively faster after doing the search this way.






          share|improve this answer













          I have no idea about node.js, and have never programmed in the same. But, from the question I feel that default query provided for findUsers() might be the culprit.




          As per Microsoft Docs, LDAP filter for
          (&(objectClass=user)(objectCategory=person))
          is sufficient for determining the users.




          In the official documentation for function findUsers(opts, callback), I can see the argument opts description about Optional parameters to extend or override functionality.



          So, I think you can override the LDAP filter query using the opts argument in findUsers function to keep the above advised LDAP filter, and additionally put your sAMAccountName condition in the search query. Please explore on how to override the opts argument, as I can't help you with that.



          I am hopeful that the result would be comparatively faster after doing the search this way.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 21 at 6:59









          Am_I_HelpfulAm_I_Helpful

          15.6k73055




          15.6k73055








          • 1





            Thank you, that is much faster.

            – Ofek Ben Yaish
            Jan 21 at 9:32











          • @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

            – Am_I_Helpful
            Jan 21 at 10:14














          • 1





            Thank you, that is much faster.

            – Ofek Ben Yaish
            Jan 21 at 9:32











          • @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

            – Am_I_Helpful
            Jan 21 at 10:14








          1




          1





          Thank you, that is much faster.

          – Ofek Ben Yaish
          Jan 21 at 9:32





          Thank you, that is much faster.

          – Ofek Ben Yaish
          Jan 21 at 9:32













          @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

          – Am_I_Helpful
          Jan 21 at 10:14





          @OfekBenYaish - Great, good to know that! Would you please comment on how fast it is, in case it might help future visitors?

          – Am_I_Helpful
          Jan 21 at 10:14




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277809%2fimprove-latency-of-findusers-query-made-by-node-js-activedirectory-module%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Liquibase includeAll doesn't find base path

          How to use setInterval in EJS file?

          Petrus Granier-Deferre