Xojo Conferences

« Thread Names | Home | Print to Printer in X… »

LDAP in FileMaker

We are adding LDAP support for FileMaker with a few functions to query, add, modify and delete values. 

To connect, you call the LDAP.Connect function and pass server IP/domain, SSL and maybe port setting. Next you call LDAP.Bind or LDAP.SimpleBind to pass your authentication data.

Once you are connected correctly, you can call the others functions. In our example we simply call the LDAP.Search function passing a query. For example we can search with Scope=Subtree through all nodes and find entries which have a given name: "(givenName=*)". This finds all people with a name.

Next we walk over all the entries found to list all the attributes and show values.

At this point you can of course redirect keys like FirstName to a matching field and import contact information.


Here our example script which does query values and show them in our example database as records: 


Delete All Records [No dialog]


Set Variable [$r; Value:MBS("LDAP.Connect"; LDAP Query::Server; LDAP Query::SSL; LDAP Query::Port)]

If [MBS("IsError")]

Show Custom Dialog ["LDAP error"; "Failed to connect." & ¶ & $r]

Exit Script []


Set Variable [$ldap; Value:$r]


Set Variable [$r; Value:MBS("LDAP.Bind"; $ldap; LDAP Query::UserName; LDAP Query::Password; LDAP Query::AuthMethod)]

If [MBS("IsError")]

Show Custom Dialog ["LDAP error"; "Failed to authenticate." & ¶ & $r]



Set Variable [$r; Value:MBS("LDAP.Search"; $ldap; LDAP Query::Base; LDAP Query::Scope; LDAP Query::Filter; ""; 0; 20; 999)]

#Check results

Set Variable [$EntryCount; Value:MBS("LDAP.SearchResult.Count"; $ldap)]

#Walk over all entries

Set Field [LDAP Query::Entry Count; $EntryCount]

If [$EntryCount > 0]

Set Variable [$EntryIndex; Value:0]


Set Variable [$EntryName; Value:MBS("LDAP.SearchResult.DistinguishedName"; $ldap; $EntryIndex)]

#Walk over all attributes

Set Variable [$AttributeCount; Value:MBS("LDAP.SearchResult.AttributeCount"; $ldap; $EntryIndex)]

If [$AttributeCount]

Set Variable [$AttributeIndex; Value:0]


#Check attribute name and value:

Set Variable [$AttributeName; Value:MBS("LDAP.SearchResult.AttributeName"; $ldap; $EntryIndex; $AttributeIndex)]

Set Variable [$AttributeValues; Value:MBS("LDAP.SearchResult.AttributeValues"; $ldap; $EntryIndex; $AttributeIndex; 1)]

#Store in a record:

New Record/Request

Set Field [LDAP Query::Entry; $EntryName]

Set Field [LDAP Query::Attribute; $AttributeName]

Set Field [LDAP Query::Values; $AttributeValues]

Commit Records/Requests [No dialog]

#next attribute

Set Variable [$AttributeIndex; Value:$AttributeIndex + 1]

Exit Loop If [$AttributeIndex = $AttributeCount]

End Loop

End If

#next entry

Set Variable [$EntryIndex; Value:$EntryIndex + 1]

Exit Loop If [$EntryIndex = $EntryCount]

End Loop

End If

End If


Set Variable [$r; Value:MBS("LDAP.Release"; $ldap)]

End If

Please try in the next days with updated 5.5pr3 plugin. We may add more functions over time if developers ask for them, e.g. to import data like pictures from LDAP server.
16 12 15 - 13:44
two comments

Hello, I’m trying the LDAP Function and it’s exciting. For the moment, I get the information with LDAP.Search.
I would like to test the modify and the add functions, but I don’t understand how to do. For the search option, I define a variable or a field with the results. That’s simple.
Wich function use in my script to insert the ldap.modify ??? If you ‘ve got other examples of FM Scripts with other ldap fonctions … i’m interested. THANKS
Bernard Mortreu - 22 09 18 - 09:57

Well, first learn how LDAP works by reading some documentation.

Than you can either use LDAP.Add/LDAP.Modify to add or modify a single value.
Or you use the JSON functions there to take a block of values and edit them all together.
Christian Schmitz (URL) - 22 09 18 - 20:08

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.