bugfixes
This commit is contained in:
@@ -5,7 +5,7 @@ module.exports = (sequelize) => {
|
||||
const Authentication = sequelize.define('Authentication', {
|
||||
ObjectGUID: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
defaultValue: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
@@ -61,7 +61,7 @@ class ActiveDirectoryManager {
|
||||
const options = {
|
||||
baseDN: this.ad.baseDN,
|
||||
filter: '(&(objectClass=user)(objectCategory=person))',
|
||||
attributes: ['ObjectGUID'
|
||||
attributes: ['objectGUID'
|
||||
,'sAMAccountName'
|
||||
,'mail'
|
||||
,'givenName'
|
||||
|
||||
@@ -253,20 +253,19 @@ async syncAuthByActiveDirectory() {
|
||||
const auth = await this.db.get('authentication');
|
||||
const all = await this.service.get('activeDirectoryManager').getAllUsers();
|
||||
|
||||
await Promise.all(
|
||||
all.map(async (user) => {
|
||||
user = {...user, userAccountControl_ID: user.userAccountControl};
|
||||
const [record, created] = await auth.findOrCreate({
|
||||
where: { dn: user.dn },
|
||||
defaults: user
|
||||
});
|
||||
|
||||
if (!created) {
|
||||
await record.update(user);
|
||||
}
|
||||
})
|
||||
);
|
||||
all.forEach(async user => {
|
||||
user.userAccountControl = user.userAccountControl_ID;
|
||||
user.distinguishedName = user.distinguishedName;
|
||||
|
||||
await auth.upsert({
|
||||
objectGUID: user.ObjectGUID,
|
||||
ObjectSource_ID: 2,
|
||||
userAccountControl_ID: user.userAccountControl,
|
||||
mail: user.mail,
|
||||
displayName: user.displayName
|
||||
});
|
||||
})
|
||||
|
||||
// return all;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user