Comments (2)
Since your code has an attribute sAMAccountName
, assume your LDAP server is Windows AD Server.
AFAIK, For changing AD password, you should use delete
operation follow a add
operation, instead of replace
operation.
replace
operation is for password reset, that is the permission of administrator. while normal user has not such permission. for ref: https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/change-windows-active-directory-user-password
another thing, when you change password, you should use LDAPS instead of LDAP. for AD server, you have to enable LDAPS manually, (default configuration is not enabled.)
Connection sample code
const url = "ldaps://xxx.xxx.xxx.xxx:636";
const client = ldap.createClient({
url: `${url}`,
tlsOptions: {
rejectUnauthorized: false
}
});
PWD change sample code:
client.search("DC=xxx,DC=xxx,DC=xxx", searchOptions, (err, res) => {
res.on('searchEntry', entry => {
let dn = entry.pojo.objectName;
client.modify(dn, [
new ldap.Change({
operation: 'delete',
modification: new ldap.Attribute({
type: 'unicodePwd',
values: encodePassword(currentPassword)
})
}),
new ldap.Change({
operation: 'add',
modification: new ldap.Attribute({
type: 'unicodePwd',
values: encodePassword(newPassword)
})
})
], function (e) {
if (e) {
resp.json({
result: "failed",
message: e
});
console.log(e);
}
else {
resp.json({
result: "success"
});
console.log('Password changed!');
}
});
});
res.on('error', e => {
console.error('error: ' + e.message);
resp.json({
result: "failed",
message: e
});
});
});
function encodePassword(password) {
return new Buffer('"' + password + '"', 'utf16le').toString();
}
from node-ldapjs.
And for TLS version, it depends on your Server Version. NodeJS is mark TLS 1.0/1.1 disabled by default. you have to make sure client and server can success have an TLS handshake.
You can capture the TLS packet by wireshark for sure.
from node-ldapjs.
Related Issues (20)
- Whitespace in (old) parseFilter causes `Uncaught Error: missing paren`
- Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme). HOT 4
- SASL / GSSAPI support HOT 3
- Open ssl issue with node 18 HOT 1
- Compatibility Issue Between ldapjs Library and FreeRADIUS HOT 1
- Edited: Ldapjs doesn't work after next.js build HOT 5
- Sharing unescape DN code for helper method
- (node:536) [LDAP_MESSAGE_DEP_001] LdapjsMessageWarning: messageID is deprecated. Use messageId instead. HOT 1
- Missing LDAP Result Codes in errors.js HOT 1
- AttributeFilter not implemented on Server? HOT 3
- What is Naming Violation Error HOT 1
- LDAPJS Server: when searching, I need to request in lowercase attributes in order to get mixed-case attributes HOT 1
- Assistance Needed with LDAPS Connection to Windows Server 2012 R2 AD HOT 2
- TLS 1.3 not supported
- Why does the bind method call fail without throwing exception information? HOT 1
- Parse Error
- Get IP of a request
- Problem binding to active directory special characters HOT 1
- res.on("searchEntry") in next.js after build does not return data. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ldapjs.