This commit is contained in:
Douglas Barone 2023-10-30 12:39:46 -04:00
parent 34f098f76f
commit 863e5b3e49
2 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import { pubsub, AUTH_UPDATED } from '../pubsub'
import { logError, logInfo, logSuccess, logWarning } from '../lib/logger'
import { performance } from 'perf_hooks'
import { attributes } from '../lib/activeDirectory/attributes'
class User {
constructor(username) {
this.username = username
@ -384,7 +385,17 @@ class User {
const startTime = performance.now()
// Do not promise.all, because it freezes the app
for (const [index, user] of allAdUsers.entries()) {
for (const [index, adUser] of allAdUsers.entries()) {
if (!adUser.sAMAccountName) continue
const user = {}
for (const attribute of attributes.user) {
if (adUser[attribute]) {
user[attribute] = adUser[attribute]
}
}
const dbUser = await prisma.user.upsert({
where: {
sAMAccountName: user.sAMAccountName

View File

@ -16,7 +16,7 @@ const entryParser = (entry, raw, callback) => {
if (raw.hasOwnProperty('lastLogonTimestamp'))
entry.lastLogonTimestamp = ldapTimeToJSDate(raw.lastLogonTimestamp)
if (raw.hasOwnProperty('lockoutTime') && entry.lockoutTime !== '0')
if (raw.hasOwnProperty('lockoutTime'))
entry.lockoutTime = ldapTimeToJSDate(raw.lockoutTime)
if (raw.hasOwnProperty('extensionAttribute7'))
@ -26,6 +26,7 @@ const entryParser = (entry, raw, callback) => {
}
function ldapTimeToJSDate(ldapTime) {
if (ldapTime === '0') return null
return new Date(ldapTime / 1e4 - 1.16444736e13)
}