openldap 0.0.2

openldap minimal binding


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

dopenldap

dlang openldap simple binding

Minimal (connect to LDAP server, synchronous search and bind) bindig to openldap C library

Usage example

import openldap;
import std.stdio;
import std.format;
import std.string;
import std.experimental.logger;

void main() {
    globalLogLevel(LogLevel.info);
    int proto_version;

    auto ldap = LDAP("ldap://ldap.forumsys.com");
    ldap.get_option(LDAP_OPT_PROTOCOL_VERSION, &proto_version);
    if ( proto_version == 2) {
        proto_version = 3;
        ldap.set_option(LDAP_OPT_PROTOCOL_VERSION, &proto_version);
        info("Switched to protocl version 3");
    }

    auto r = ldap.search_s("dc=example,dc=com",
        LDAP_SCOPE_SUBTREE, "(uid=%s)".format("einstein"));
    infof("Found dn: %s", r[0].dn);
    foreach(k,v; r[0].entry) {
        infof("%s = %s", k, v);
    }

    int b = ldap.bind_s(r[0].dn, "password");
    infof("Bind using 'password': %s", b==0?"OK":"Fail");
    ldap.unbind();
}
Authors:
igor
Dependencies:
none
Versions:
0.0.2 2015-Dec-26
~master 2015-Dec-26
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 69 downloads total