Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "ldap4pl"

Title:LDAP interface
Rating:Not rated. Create the first rating!
Latest version:0.1
SHA1 sum:ea4fed4b5efc36db033a972e862b52fb534c91af
Author:Hongxin Liang <hongxin.liang@ericsson.com>
Maintainer:Hongxin Liang <hongxin.liang@ericsson.com>
Packager:Hongxin Liang <hongxin.liang@ericsson.com>
Home page:https://github.com/EricssonResearch/ldap4pl
Download URL:https://github.com/EricssonResearch/ldap4pl/archive/v0.1.zip

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.1a9c2c16e4b77d22280a3815f975b3bc5104197101https://github.com/EricssonResearch/ldap4pl.git
ea4fed4b5efc36db033a972e862b52fb534c91af39https://github.com/EricssonResearch/ldap4pl.git

ldap4pl

This package provides Prolog bindings for OpenLDAP API.

Most APIs have been implemented and the names are aligned with OpenLDAP API, so for detailed description please check here.

Verified with OpenLDAP 2.4.x.

Installation

Using SWI-Prolog 7 or later.

?- pack_install('https://github.com/EricssonResearch/ldap4pl.git').

Compilation on Mac OS X and GNU Linux has been verified, not on Windows.

Source code available and pull requests accepted here.

author
- Hongxin Liang <hongxin.liang@ericsson.com>
license
- Apache License Version 2.0

Examples

To search asynchrously:

:- use_module(library(ldap4pl)).
:- use_module(library(ldap4pl_util)).

search :-
    ldap_initialize(LDAP, 'ldap://example.org'),
    ldap_set_option(LDAP, ldap_opt_protocol_version, 3),
    ldap_simple_bind_s(LDAP, 'cn=...,dc=...,dc=...,dc=...', passwd),
    ldap_search(LDAP,
        query(
            base('dc=...,dc=...,dc=...'),
            scope(ldap_scope_onelevel),
            filter('(objectClass=*)'),
            attrs([objectClass, sambaDomainName]),
            attrsonly(false)
        ),
        MsgID),
    ldap_result(LDAP, MsgID, true, Result),
    ldap_parse_result(LDAP, Result, _, _, _, _, _, false),
    ldap_parse_search_result(LDAP, Result, List),
    print_term(List, []),
    ldap_msgfree(Result),
    ldap_unbind(LDAP).

To do a simple auth:

:- use_module(library(ldap4pl)).
:- use_module(library(ldap4pl_util)).

auth :-
    ldap_simple_auth('ldap://example.org',
        'cn=...,dc=...,dc=...,dc=...',
        passwd).

To add a new entry:

:- use_module(library(ldap4pl)).
:- use_module(library(ldap4pl_util)).

add :-
    ldap_initialize(LDAP, 'ldap://example.org'),
    ldap_set_option(LDAP, ldap_opt_protocol_version, 3),
    ldap_simple_bind_s(LDAP, 'cn=...,dc=...,dc=...,dc=...', passwd),
    DN = 'cn=...,ou=groups,dc=...,dc=...,dc=...',
    ldap_add_s2(LDAP, DN, _{objectClass:[posixGroup, top], cn:test, gidNumber:'20000', description:hello}),
    ldap_unbind(LDAP).

For more examples, please check source code under examples directory.

License

Copyright 2015 Ericsson

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contents of pack "ldap4pl"

Pack contains 9 files holding a total of 141K bytes.