Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5    Statistic    FMM    Blog  

LDAP.JSON

Queries JSON structure of LDAP data.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
LDAP JSON 8.0 Yes Yes Yes Yes No
MBS( "LDAP.JSON"; LDAPRef )   More

Parameters

Parameter Description Example
LDAPRef The reference number for the LDAP connection. $ldap

Result

Returns OK or error.

Description

Queries JSON structure of LDAP data.
Please first search, then query here the result as JSON.

Examples

Query JSON:

# Connect
Set Variable [ $r ; Value: MBS("LDAP.Connect"; "ldap.forumsys.com"; 0; 389) ]
If [ MBS("IsError") ]
    Show Custom Dialog [ "LDAP error" ; "Failed to connect." & ¶ & $r ]
Else
    Set Variable [ $ldap ; Value: $r ]
    # Login
    Set Variable [ $r ; Value: MBS("LDAP.Bind"; $ldap; "uid=tesla,dc=example,dc=com"; "password"; "simple") ]
    If [ MBS("IsError") ]
        Show Custom Dialog [ "LDAP error" ; "Failed to authenticate." & ¶ & $r ]
    Else
        # Search
        Set Variable [ $r ; Value: MBS("LDAP.Search"; $ldap; "dc=example,dc=com"; "subtree"; "(givenName=*)"; ""; 0; 20; 999) ]
        # Check results
        Show Custom Dialog [ "JSON" ; MBS("LDAP.JSON"; $ldap) ]
    End If
    # Cleanup
    Set Variable [ $r ; Value: MBS("LDAP.Release"; $ldap) ]
End If

Example result:
[{
    "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"]
      }]
  }]

Query a person via JSON:

Set Variable [ $ldap ; Value: MBS("LDAP.Connect"; "ldap.test.de"; 0; 389 ) ]
Set Variable [ $r ; Value: MBS("LDAP.Bind"; $ldap; "cn=admin,dc=ldap,dc=test,dc=de"; "S2A2S@home"; "simple" ) ]
Set Variable [ $r ; Value: MBS("LDAP.Search"; $ldap; "ou=Users,dc=ldap,dc=test,dc=de"; "Subtree"; ""; ""; 0; 20; 999) ]
Set Field [ Employee::_LDAP.JSON.QUERY ; MBS("LDAP.JSON"; $ldap) ]
Set Variable [ $r ; Value: MBS("LDAP.Release"; $ldap) ]

Example result:
[
  {
    "dn":   "ou=Users,dc=ldap,dc=test,dc=de",
    "attributes":   [
      {
        "name":   "objectClass",
        "values":   [
          "organizationalUnit",
          "top"
        ]
      },
      {
        "name":   "ou",
        "values":   [
          "Users"
        ]
      }
    ]
  },
  {
    "dn":   "uid=bob.miller,ou=Users,dc=ldap,dc=test,dc=de",
    "attributes":   [
      {
        "name":   "objectClass",
        "values":   [
          "posixAccount",
          "shadowAccount",
          "top",
          "inetOrgPerson",
          "organizationalPerson",
          "person"
        ]
      },
      {
        "name":   "uid",
        "values":   [
          "bob.miller"
        ]
      },
      {
        "name":   "uidNumber",
        "values":   ["1"]
      },
      {
        "name":   "cn",
        "values":   [
          "Bob Miller"
        ]
      },
      {
        "name":   "mail",
        "values":   [
          "bob.miller@test.de"
        ]
      },
      {
        "name":   "homeDirectory",
        "values":   [
          "/usr/local/var/"
        ]
      },
      {
        "name":   "sn",
        "values":   [
          "Miller"
        ]
      },
      {
        "name":   "employeeType",
        "values":   [
          "Employee"
        ]
      },
      {
        "name":   "givenName",
        "values":   [
          "Bob"
        ]
      },
      {
        "name":   "employeeNumber",
        "values":   ["77"]
      },
      {
        "name":   "userPassword",
        "values":   [
          "xxxx"
        ]
      },
      {
        "name":   "gidNumber",
        "values":   ["100"]
      }
    ]
  }
]

See also

Blog Entries

Release notes

Created 11st December 2017, last changed 29th February 2020


LDAP.GetTimeOut   -   LDAP.Modify

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins