-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcustomizer_DSM7_IDs_string2int.js
77 lines (60 loc) · 2.59 KB
/
customizer_DSM7_IDs_string2int.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
'use strict';
const config = require('../config');
const helper = require('../helper');
var customizer = {};
// all possible funcitons
// customizer.ModifyLDAPUser = function (ldapuser, azureuser) { return ldapuser; };
// customizer.ModifyLDAPGroup = function (ldapgroup, azuregroup) { return ldapgroup; };
// customizer.ModifyLDAPGlobal = function (all) { return all; };
// customizer.ModifyAzureUsers = function (azureusers) { return azureusers; };
// customizer.ModifyAzureGroups = function (azuregroups) { return azuregroups; };
// convert gidNumber from string to int
customizer.ModifyLDAPGroup = function (ldapgroup, azuregroup) {
helper.log("customizer", "ModifyLDAPGroup", "called");
if (ldapgroup.hasOwnProperty("gidNumber")) {
let parsed = parseInt(ldapgroup.gidNumber);
if (isNaN(parsed)) parsed = ldapgroup.gidNumber;
ldapgroup.gidNumber = parsed;
}
return ldapgroup;
};
// convert gidNumber from string to int
customizer.ModifyLDAPUser = function (ldapuser, azureuser) {
helper.log("customizer", "ModifyLDAPUser", "called");
if (ldapuser.hasOwnProperty("gidNumber")) {
let parsed = parseInt(ldapuser.gidNumber);
if (isNaN(parsed)) parsed = ldapuser.gidNumber;
ldapuser.gidNumber = parsed;
}
if (ldapuser.hasOwnProperty("uidNumber")) {
let parsed = parseInt(ldapuser.uidNumber);
if (isNaN(parsed)) parsed = ldapuser.uidNumber;
ldapuser.uidNumber = parsed;
}
return ldapuser;
};
customizer.ModifyLDAPGlobal = function (all) {
let root = "uid=root," + config.LDAP_USERSDN;
for (var key of Object.keys(all)) {
//console.log(`${key}= ${value}`);
all[key].creatorsName = root;
if (!all[key].hasOwnProperty("createTimestamp"))
all[key].createTimestamp = helper.ldap_now() + "Z";
if (!all[key].hasOwnProperty("entryCSN"))
all[key].entryCSN = helper.ldap_now() + ".000000Z#000000#000#000000";
all[key].modifiersName = root;
if (!all[key].hasOwnProperty("modifyTimestamp"))
all[key].modifyTimestamp = all[key].createTimestamp;
if (all[key].hasOwnProperty("sambaDomainName")) {
all[key].sambaDomainName = all[key].sambaDomainName.toLowerCase();
}
}
return all;
};
// only users in my domain
/*
customizer.ModifyAzureUsers = function (azureusers) {
return Object.values(azureusers).filter(u => u.hasOwnProperty("givenName") && u.hasOwnProperty("userPrincipalName") && u.givenName != null && u.userPrincipalName.toString().endsWith(config.LDAP_DOMAIN));
};
*/
module.exports = customizer;