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.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
LDAP.Connect
Initializes an LDAP connection.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| LDAP | 6.0 | Yes | Yes | Yes | Yes | No |
Parameters
| 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. |
"192.168.2.222" |
| SSL | Whether to use SSL. 1 to enable or 0 to not enable. |
1 |
| Port | The port to use. If zero or undefined, the default port is used. e.g. 636 for LDAPS or 389 for LDAP. |
3889 |
Result
Returns reference number or error.
Description
Initializes an LDAP connection.Returns the references number which you pass to other LDAP functions.
Please call LDAP.Release later to close connection.
Examples
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"; "192.168.1.123"; 1; 3636)
Connect using URL:
MBS( "LDAP.Connect"; "ldaps://192.168.1.123")
Connect and Query:
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
See also
- IsError
- LDAP.AddJSON
- LDAP.Bind
- LDAP.JSON
- LDAP.Search
- LDAP.SearchResult.AttributeCount
- LDAP.SearchResult.AttributeName
- LDAP.SearchResult.AttributeValue
- LDAP.SearchResult.AttributeValues
- LDAP.SearchResult.DistinguishedName
Example Databases
Blog Entries
Created 15th December 2015, last changed 20th November 2017
Feedback: Report problem or ask question.
Links
MBS Xojo Plugins