Search code examples
javascriptnode.jsntlm

Check if Windows Username and Password is correct in NodeJs


I have a NodeJs application with certain parameters. Some of them are a Username and a Password.

I am trying to figure out whether there is a way I can check if the Password provided for the given UserName is the right one according to Active Directory.

On my C# application, I can do something like this

bool isValid = pc.ValidateCredentials(UserName, Password, ContextOptions.Negotiate);

but... how to do something similar in NodeJs?

EDIT: In other words, I am trying to figure out given a UserName and Password that are part of a Windows domain, check whether the password is correct.

Example: UserName: user@domain.com PassWord: password123!

I am wondering how to validate windows domain credentials using NodeJS


Solution

  • You need an Active Directory lib that you can use in NodeJS.

    A few samples include:

    Basically, through LDAP (packages of LDAP on npm) you could check if you are able to make a simple bind with the Active Directory, and therefore if the credentials are working.