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  


Initializes an LDAP connection.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
LDAP 6.0 Yes Yes Yes Yes No
MBS( "LDAP.Connect"; IP; SSL; Port )   More


Parameter Description Example
IP The IP or domain name of the server.
If prefixed with ldap:// or ldaps://, the plugin will remove that prefix.
If prefix is ldaps://, the plugin will assume SSL is enabled.
SSL Whether to use SSL.
1 to enable or 0 to not enable.
Port The port to use.
If zero or undefined, the default port is used.
e.g. 636 for LDAPS or 389 for LDAP.


Returns reference number or error.


Initializes an LDAP connection.
Returns the references number which you pass to other LDAP functions.
Please call LDAP.Release later to close connection.


Connect to local LDAP server:

MBS( "LDAP.Connect"; "localhost"; 0; 389 )

Connect to LDAP server:

MBS( "LDAP.Connect"; "ldap.internal"; 1)

Connect via IP and special port:

MBS( "LDAP.Connect"; ""; 1; 3636)

Connect using URL:

MBS( "LDAP.Connect"; "ldaps://")

Connect and Query:

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

See also

Example Databases

Blog Entries

Created 15th December 2015, last changed 20th November 2017

LDAP.Bind   -   LDAP.Delete

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins