« FileMaker Cloud Tipps… | Home | MBS FileMaker Plugin,… »

LDAP with JSON

For the next plugin prerelease, we introduce three JSON functions for use with our LDAP functions.

So you can use query and get the result as JSON with the new LDAP.JSON function. See this little example which connects and makes a query and finally shows the JSON in a dialog:

# Connect

Variable setzen [ $r ; Wert: MBS("LDAP.Connect"; "ldap.forumsys.com"; 0; 389) ] 

Wenn [ MBS("IsError") ] 

Eigenes Dialogfeld anzeigen [ "LDAP error" ; "Failed to connect." & ¶ & $r ] 

Sonst

Variable setzen [ $ldap ; Wert: $r ] 

# Login

Variable setzen [ $r ; Wert: MBS("LDAP.Bind"; $ldap; "uid=tesla,dc=example,dc=com"; "password"; "simple") ] 

Wenn [ MBS("IsError") ] 

Eigenes Dialogfeld anzeigen [ "LDAP error" ; "Failed to authenticate." & ¶ & $r ] 

Sonst

# Search

Variable setzen [ $r ; Wert: MBS("LDAP.Search"; $ldap; "dc=example,dc=com"; "subtree"; "(givenName=*)"; ""; 0; 20; 999) ] 

# Check results

Eigenes Dialogfeld anzeigen [ "JSON" ; MBS("LDAP.JSON"; $ldap) ] 

Ende (wenn)

# Cleanup

Variable setzen [ $r ; Wert: MBS("LDAP.Release"; $ldap) ] 

Ende (wenn)

 
The answer in JSON looks like this:
 

[{

"dn": "uid=test,dc=example,dc=com",

"attributes": [{

"name": "objectClass",

"values": ["posixAccount", "top", "inetOrgPerson"]

}, {

"name": "gidNumber",

"values": ["0"]

}, {

"name": "givenName",

"values": ["Test"]

}, {

"name": "sn",

"values": ["Test"]

}, {

"name": "displayName",

"values": ["Test"]

}, {

"name": "uid",

"values": ["test"]

}, {

"name": "initials",

"values": ["TS"]

}, {

"name": "homeDirectory",

"values": ["home"]

}, {

"name": "cn",

"values": ["Test"]

}, {

"name": "uidNumber",

"values": ["24601"]

}, {

"name": "o",

"values": ["Company"]

}]

}]
 
So we have an array of entries fill with an object for each entry. Each entry has attributes and there each value can have several values. 
 
For add, modify or delete, you can now use the LDAP.AddJSON and LDAP.ModifyJSON functions to pass in JSON formatted changes.
The structure looks like this:

[{
    "operation": "Add",
    "type": "xxx",
    "values": ["Hello", "World"]
},
{
    "operation": "Replace",
    "type": "yyy",
    "value": "Other"
},
{
    "operation": "Delete",
    "type": "zzz"
}]

Please try in next prelease.

Claris FileMaker Plugin
11 12 17 - 13:37