This commit is contained in:
XD 2022-10-19 22:34:06 +08:00
parent b41a944c62
commit b75dbf3e7f
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import {ldapConfig} from "../ldap.config";
import {createHash} from "crypto";
import {createHash, randomUUID} from "crypto";
import {randomStringGenerator} from "@nestjs/common/utils/random-string-generator.util";
export function getRootDN() {
return ldapConfig.rootDN;
@ -65,6 +66,9 @@ export function makePersonEntry(dn, attrs) {
// };
// const generatedDN = makeOrganizationUnitEntryDN(dn);
const generatedDN = makeDN(dn, getRootDN());
if (attrs.userPassword===''){
attrs.userPassword = randomUUID();
}
const shaPassword = createHash('sha1').update(attrs.userPassword);
const base64ShaPassword = shaPassword.digest('base64');
attrs.userPassword = '{SHA}' + base64ShaPassword;