« 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]

#Connect

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 []

Else

Set Variable [$ldap; Value:$r]

#Login

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]

Else

#Search

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]

Loop

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]

Loop

#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

#Cleanup

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
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
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.