我使用ldapjs
nodejs 模块与我的active directory
.
我可以使用这些功能将用户绑定并添加到活动目录中......
ldapOptions = {
url: //my ldap server ip,
connectionTimeOut: 30000,
reconnect: true
}
const ldapClient = ldapJs.createClient(ldapOptions)
ldapClient.bind(adminDn, adminPass, (error) => {
if (error) {
// break the code
} else {
let newUser = {
cn: username,
sn: username,
description: // some desc,
objectClass: ['inetOrgPerson', 'user', 'person', 'top'],
userPassword: password
}
ldapClient.add(dn, newUser, err => {
if (err) {
console.log(err)
// break the code
} else {
console.log('success')
}
}
}
但在添加进程后,该帐户是
disabled
和用户must change password
a 下一次登录。这是默认的活动目录策略还是 ldapjs 默认值?如果是我如何更改默认值...
Update
我Active Directory Certificate Service
在我的 Windows 服务器上处于活动状态(活动目录)
之后,将该证书导出到活动目录并添加到我机器上的信任证书中......
ldapjs 文档建议使用 nodejs/tls 选项与ldaps
服务器通信...
const ldapOptions = {
url: 'ldaps://test-server.part.loc',
connectTimeout: 1000,
reconnect: false,
tlsOptions: {
// key and cert is create on my own but just created by openssl. do i have ti trusted it to my machine or server?
key: fs.readFileSync('my_cert.pem'),
cert: fs.readFileSync('my_key.pem'),
// this is the certificate of the active directory
ca: fs.readFileSync('fuck_cert.pem'),
checkServerIdentity: () => { return null; },
}
}
但仍然收到错误:
Error: error:0909006C:PEM routines:get_name:no start line
库:“PEM 例程”,
功能:'get_name',
原因:'没有起跑线',
代码:'ERR_OSSL_PEM_NO_START_LINE'