Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
d6dfcd45
Commit
d6dfcd45
authored
4 years ago
by
Sebastian Listl
Browse files
Options
Downloads
Patches
Plain Diff
ActiveDirectory import formatting fixes
parent
f057fd67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
process/ActiveDirectoryXml_lib/process.js
+486
-476
486 additions, 476 deletions
process/ActiveDirectoryXml_lib/process.js
process/ActiveDirectory_lib/process.js
+40
-22
40 additions, 22 deletions
process/ActiveDirectory_lib/process.js
with
526 additions
and
498 deletions
process/ActiveDirectoryXml_lib/process.js
+
486
−
476
View file @
d6dfcd45
This diff is collapsed.
Click to expand it.
process/ActiveDirectory_lib/process.js
+
40
−
22
View file @
d6dfcd45
...
...
@@ -11,6 +11,8 @@ import("system.tools");
import
(
"
system.project
"
);
import
(
"
ActiveDirectoryXml_lib
"
);
//TODO: add comments to methods
var
ColumnMetadataProvider
=
(
function
()
{
var
metadataInstance
=
{};
...
...
@@ -104,7 +106,7 @@ LdapImporter.prototype.getLdapConfig = function()
LdapImporter
.
prototype
.
createSearchAction
=
function
()
{
var
ldapConfiguration
=
this
.
getLdapConfig
();
var
dataMappingKeys
=
Object
.
keys
(
this
.
dataMapping
);
//TODO: good/bad?
var
dataMappingKeys
=
Object
.
keys
(
this
.
dataMapping
);
var
attributeArray
=
dataMappingKeys
.
map
(
function
(
key
)
{
return
new
LDAPAttribute
(
key
);
});
...
...
@@ -184,7 +186,8 @@ LdapImporter.prototype.process = function()
var
usersMissingInLdap
=
{};
//only keep internal userid to ensure a small memory footprint
//first, collect users that are in ADITO and should be in LDAP
tools
.
getStoredUsers
().
forEach
(
function
(
user
,
idx
)
{
tools
.
getStoredUsers
().
forEach
(
function
(
user
,
idx
)
{
if
(
USERMODEL_IDENTIFIER
==
tools
.
NAME
)
usersMissingInLdap
[
user
[
0
]]
=
idx
;
else
if
(
USERMODEL_IDENTIFIER
==
tools
.
TITLE
)
...
...
@@ -239,7 +242,8 @@ LdapImporter.prototype._createAditoKeyValueArray = function(pLdapAttribute)
{
let
ldapAttributes
=
{};
for
(
var
[
key
,
mapping
]
in
this
.
dataMapping
)
{
for
(
var
[
key
,
mapping
]
in
this
.
dataMapping
)
{
if
(
mapping
.
FIELD_NAME
)
{
mapping
.
FIELD_NAME
.
forEach
(
function
(
fieldName
){
...
...
@@ -260,11 +264,12 @@ LdapImporter.prototype._prepareLdapValue = function (pPreparedValue, pMapping, p
{
pPreparedValue
=
(
pPreparedValue
==
null
||
pPreparedValue
.
getValues
()
==
null
)
?
""
:
pPreparedValue
.
getValues
().
toString
();
if
(
pMapping
.
FUNCTION
)
{
if
(
pMapping
.
FUNCTION
)
{
if
(
typeof
pMapping
.
FUNCTION
==
"
function
"
)
pPreparedValue
=
pMapping
.
FUNCTION
(
pPreparedValue
,
pMapping
,
pLdapAttributeObj
,
pLdapAttributName
,
pAditoKeyValueArray
);
else
pPreparedValue
=
eval
(
pMapping
.
FUNCTION
);
//
else
//
pPreparedValue = eval(pMapping.FUNCTION);
}
else
if
(
pMapping
.
MAPPING
)
{
pPreparedValue
=
this
.
_mappingLdapValue
(
pPreparedValue
,
pMapping
,
pLdapAttributeObj
,
pLdapAttributName
,
pAditoKeyValueArray
);
}
...
...
@@ -284,14 +289,20 @@ LdapImporter.prototype._mappingLdapValue = function(pPreparedValue, pMapping, pL
{
let
valuesToAssign
=
[];
for
(
var
key
in
pMapping
.
MAPPING
)
{
if
(
pPreparedValue
.
match
(
key
))
{
for
(
var
key
in
pMapping
.
MAPPING
)
{
if
(
pPreparedValue
.
match
(
key
))
{
var
mapValues
=
pMapping
.
MAPPING
[
key
];
if
(
typeof
mapValues
==
"
string
"
)
{
if
(
mapValues
[
0
]
==
"
;
"
&&
mapValues
[
mapValues
.
length
-
1
]
==
"
;
"
)
{
if
(
typeof
mapValues
==
"
string
"
)
{
if
(
mapValues
[
0
]
==
"
;
"
&&
mapValues
[
mapValues
.
length
-
1
]
==
"
;
"
)
{
mapValues
=
text
.
decodeMS
(
mapValues
);
}
else
{
}
else
{
mapValues
=
[
mapValues
];
}
}
...
...
@@ -355,10 +366,13 @@ ActiveDirectoryUtils._createUpdateUserDatamodel = function (pDataSet, pUserModel
effectiveUserModel
[
tools
.
PARAMS
][
tools
.
EXCHANGE_EMAIL
]
=
effectiveUserModel
[
tools
.
PARAMS
][
tools
.
EXCHANGE_EMAIL
].
toLowerCase
();
if
(
mode
==
LDAP_ACTION
.
INSERT
)
try
{
try
{
logging
.
log
(
"
insert User Model
"
);
tools
.
insertUser
(
effectiveUserModel
);
}
catch
(
onInsertException
)
{
}
catch
(
onInsertException
)
{
logging
.
log
(
effectiveUserModel
[
tools
.
NAME
])
logging
.
log
(
"
Error insert User:
"
+
effectiveUserModel
[
tools
.
TITLE
],
logging
.
ERROR
,
onInsertException
);
logging
.
log
(
JSON
.
stringify
(
effectiveUserModel
,
null
,
"
"
),
logging
.
ERROR
);
...
...
@@ -366,7 +380,6 @@ ActiveDirectoryUtils._createUpdateUserDatamodel = function (pDataSet, pUserModel
else
tools
.
updateUser
(
effectiveUserModel
);
}
ActiveDirectoryUtils
.
_createInsertUpdateCommMixStatements
=
function
(
pDataSet
,
pContactId
)
...
...
@@ -378,9 +391,9 @@ ActiveDirectoryUtils._createInsertUpdateCommMixStatements = function (pDataSet,
var
existingCommData
=
null
;
//only load when necessary, so let's load later
for
(
var
commType
in
this
.
custom
.
commTypes
)
for
(
var
commType
in
this
.
custom
.
commTypes
)
{
if
(
pDataSet
[
commType
]
==
null
||
!
ActiveDirectoryUtils
.
_isCorrectLdapAction
(
pDataSet
[
commType
],
ldapAction
))
if
(
pDataSet
[
commType
]
==
null
||
!
ActiveDirectoryUtils
.
_isCorrectLdapAction
(
pDataSet
[
commType
],
ldapAction
))
continue
;
var
commMedium
=
this
.
custom
.
commTypes
[
commType
].
MEDIUM
;
if
(
ldapAction
==
LDAP_ACTION
.
INSERT
)
...
...
@@ -428,18 +441,22 @@ ActiveDirectoryUtils._createInsertUpdateCommMixStatements = function (pDataSet,
var
isCommExists
=
false
;
var
isCommEqual
=
false
;
for
each
(
var
[
MEDIUM_ID
,
ISSTANDARD
,
ADDR
]
in
existingCommData
)
{
if
(
MEDIUM_ID
==
commMedium
)
{
for
each
(
var
[
MEDIUM_ID
,
ISSTANDARD
,
ADDR
]
in
existingCommData
)
{
if
(
MEDIUM_ID
==
commMedium
)
{
isCommExists
=
true
;
if
(
ADDR
.
trim
()
==
pDataSet
[
commType
].
VALUE
.
trim
()){
if
(
ADDR
.
trim
()
==
pDataSet
[
commType
].
VALUE
.
trim
())
{
isCommEqual
=
true
;
}
break
;
}
}
if
(
!
isCommExists
)
{
if
(
!
isCommExists
)
{
ActiveDirectoryUtils
.
_setDataObject
(
pDataSet
,
"
COMMUNICATION.COMMUNICATIONID
"
,
util
.
getNewUUID
());
ActiveDirectoryUtils
.
_setDataObject
(
pDataSet
,
"
COMMUNICATION.MEDIUM_ID
"
,
commMedium
);
ActiveDirectoryUtils
.
_setDataObject
(
pDataSet
,
"
COMMUNICATION.ADDR
"
,
pDataSet
[
commType
].
VALUE
);
...
...
@@ -450,7 +467,7 @@ ActiveDirectoryUtils._createInsertUpdateCommMixStatements = function (pDataSet,
if
(
tmpInsUpdC
!=
null
)
sqlMixDataSet
.
push
(
tmpInsUpdC
)
}
else
if
(
!
isCommEqual
)
else
if
(
!
isCommEqual
)
{
ActiveDirectoryUtils
.
_setDataObject
(
pDataSet
,
"
COMMUNICATION.MEDIUM_ID
"
,
commMedium
);
ActiveDirectoryUtils
.
_setDataObject
(
pDataSet
,
"
COMMUNICATION.ADDR
"
,
pDataSet
[
commType
].
VALUE
);
...
...
@@ -490,7 +507,8 @@ ActiveDirectoryUtils._getColumnsAndTypesArray = function (pTableName, pDataSet,
};
var
tableConfig
=
ColumnMetadataProvider
.
getInstanceFor
(
pTableName
);
tableConfig
.
columns
.
forEach
(
function
(
column
,
idx
){
tableConfig
.
columns
.
forEach
(
function
(
column
,
idx
)
{
var
dataSet
=
pDataSet
[
pTableName
+
"
.
"
+
column
];
if
(
dataSet
==
null
||
!
ActiveDirectoryUtils
.
_isCorrectLdapAction
(
dataSet
,
pDbAction
))
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment