170
APPL/API2/plugins/scimusers.wsc
Normal file
170
APPL/API2/plugins/scimusers.wsc
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0"?>
|
||||
<component>
|
||||
<?component error="true" debug="true"?>
|
||||
<registration
|
||||
description="scimusers"
|
||||
progid="flexwhere.WSC"
|
||||
version="1.00"
|
||||
classid="{6D817B6F-9D08-4636-AAD9-8BD7C5EFF56A}"
|
||||
>
|
||||
</registration>
|
||||
|
||||
<public>
|
||||
|
||||
<!-- properties -->
|
||||
|
||||
<!-- methods -->
|
||||
<method name="initialize">
|
||||
<PARAMETER name="params"/>
|
||||
</method>
|
||||
<method name="transform_filter">
|
||||
<PARAMETER name="filter"/>
|
||||
</method>
|
||||
<method name="transform_outgoing">
|
||||
<PARAMETER name="params"/>
|
||||
<PARAMETER name="data"/>
|
||||
</method>
|
||||
<method name="transform_incoming">
|
||||
<PARAMETER name="params"/>
|
||||
<PARAMETER name="data"/>
|
||||
</method>
|
||||
</public>
|
||||
|
||||
<script language="javascript">
|
||||
<![CDATA[
|
||||
|
||||
/* properties */
|
||||
|
||||
|
||||
/* methods */
|
||||
/*
|
||||
/*
|
||||
$Id$
|
||||
|
||||
File: scimusers.wsc
|
||||
*/
|
||||
/* Globals */
|
||||
var FCLT;
|
||||
|
||||
// De omschrijving van de objecten in FACILITOR moet FW1, FW2 etc. zijn
|
||||
var scimusers_srtdeel_key = 258418;
|
||||
|
||||
function initialize(params)
|
||||
{
|
||||
FCLT = params;
|
||||
}
|
||||
|
||||
function transform_filter(filter)
|
||||
{
|
||||
filter.limit = filter.count;
|
||||
return filter;
|
||||
}
|
||||
|
||||
// We krijgen bijvoorbeeld: {"RMS":[1,-10,-11,-12,-13,-14,-15,-16,-17,2,3,-4,-5,-6,-7,-8,-9]}
|
||||
// Als het object aan staat wordt de id opgeleverd, anders -id
|
||||
function transform_incoming(params, data)
|
||||
{
|
||||
var result = [];
|
||||
if (!("RMS" in data))
|
||||
return null;
|
||||
|
||||
for (var obj in data.RMS)
|
||||
{
|
||||
var fw = data.RMS[obj];
|
||||
var state = fw > 0 ? "1": "0";
|
||||
var fw_id = "FW" + String(Math.abs(fw));
|
||||
var sql = "SELECT ins_deel_key"
|
||||
+ " FROM ins_deel"
|
||||
+ " WHERE ins_deel_verwijder IS NULL"
|
||||
+ " AND ins_srtdeel_key = " + scimusers_srtdeel_key
|
||||
+ " AND ins_deel_omschrijving = " + FCLT.safe.quoted_sql(fw_id);
|
||||
var oRs = FCLT.Oracle.Execute(sql);
|
||||
if (!oRs.Eof)
|
||||
{
|
||||
result.push({
|
||||
"id": oRs("ins_deel_key").Value,
|
||||
"state": state
|
||||
//"statedate": "2014-07-08T15:29:31Z",
|
||||
})
|
||||
}
|
||||
oRs.Close()
|
||||
}
|
||||
return { objects: result };
|
||||
}
|
||||
|
||||
function transform_outgoing(params, data)
|
||||
{
|
||||
var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
|
||||
var allusers = [];
|
||||
for (var i = 0; i < data.persons.length; i++)
|
||||
{
|
||||
var person = data.persons[i];
|
||||
var eTag = '"' + oCrypto.hex_sha1(FCLT.DEZE.JSON.stringify(person)).toLowerCase() + '"';
|
||||
// if (allusers.length > 9)
|
||||
// break;
|
||||
FCLT.DEZE.__DoLog(person);
|
||||
var unique = FCLT.DEZE.customerId + "_person_" + String(person.id);
|
||||
var oneuser = {
|
||||
"userName":person.login,
|
||||
// "externalId":person.login, deze is aangeleverd door het externe systeem, person.externalid VARCHAR(320)
|
||||
"id":unique,
|
||||
"name":{
|
||||
"formatted":person.name,
|
||||
"familyName":person.lastname,
|
||||
"givenName":person.firstname
|
||||
},
|
||||
"schemas":[
|
||||
"urn:ietf:params:scim:schemas:core:2.0:User",
|
||||
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
|
||||
],
|
||||
"displayName":person.name,
|
||||
"meta":{
|
||||
"created":person.created,
|
||||
"lastModified":person.lastchange,
|
||||
"location":FCLT.DEZE.HTTP.urlzelf() + "/SCIM/Users/" + unique,
|
||||
"version":"W/" + eTag, // Weak eTag?
|
||||
"resourceType":"User"
|
||||
},
|
||||
"userType":person["function"].name,
|
||||
"emails":[
|
||||
{
|
||||
"value":person.email,
|
||||
"type":"work",
|
||||
"primary":true
|
||||
}
|
||||
],
|
||||
"phoneNumbers":[
|
||||
{
|
||||
"value":person.phone,
|
||||
"type":"work",
|
||||
"primary":true
|
||||
}
|
||||
],
|
||||
"groups":[]
|
||||
}
|
||||
var allgroups = [];
|
||||
for (var j = 0; j < person.authorization.length; j++)
|
||||
{
|
||||
var group = person.authorization[j];
|
||||
var unique = FCLT.DEZE.customerId + "_authorization_" + String(group.authorizationgroup.id);
|
||||
oneuser.groups.push({
|
||||
"value":unique,
|
||||
"$ref":FCLT.DEZE.HTTP.urlzelf() + "/SCIM/Groups/" + unique,
|
||||
"display":group.authorizationgroup.name
|
||||
})
|
||||
}
|
||||
allusers.push(oneuser);
|
||||
}
|
||||
|
||||
return {
|
||||
"totalResults": allusers.length,
|
||||
"itemsPerPage": 10,
|
||||
"startIndex": 1,
|
||||
"schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
|
||||
"Resources": allusers
|
||||
};
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</component>
|
||||
Reference in New Issue
Block a user