LDAP with JSON
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)
[{
"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"]
}]
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.