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