https://github.com/webfreak001/ldap
D LDAP client library using winldap on windows and openldap on other platforms
https://github.com/webfreak001/ldap
active-directory d ldap openldap
Last synced: 3 months ago
JSON representation
D LDAP client library using winldap on windows and openldap on other platforms
- Host: GitHub
- URL: https://github.com/webfreak001/ldap
- Owner: WebFreak001
- Created: 2017-03-09T15:37:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T12:02:38.000Z (about 3 years ago)
- Last Synced: 2025-02-28T14:47:01.660Z (over 1 year ago)
- Topics: active-directory, d, ldap, openldap
- Language: D
- Size: 14.6 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ldap
Cross platform Microsoft Active Directory client using LDAP (winldap on windows, openldap otherwise).
---
For **secure LDAP authentication** you will want to use [ldapauth](https://github.com/symmetryinvestments/ldapauth) instead.
---
Openldap implementation based off [dopenldap](https://github.com/ikod/dopenldap)
```d
import std.stdio;
int proto_version;
auto ldap = LDAPConnection("127.0.0.1:389"); // normal ldap connection
auto auther = LDAPAuthenticationEngine("127.0.0.1:389"); // ldap connection with fast binding and no encryption support on windows (used for password authentication)
ldap.getOption(LDAP_OPT_PROTOCOL_VERSION, &proto_version);
if (proto_version == 2)
{
proto_version = 3;
ldap.setOption(LDAP_OPT_PROTOCOL_VERSION, &proto_version);
writeln("Switched to protocol version 3");
}
ldap.bind("admin@localhost", "");
auto arr = ldap.search("OU=data,DC=data,DC=local",
LDAPSearchScope.subTree, "(|(objectClass=contact)(objectClass=user))", ["l"]); // find all users & contacts
writefln("Found %s results", arr.length);
foreach (r; arr)
{
writeln(r.distinguishedName); // print path of contact
foreach (k, v; r.attributes)
{
writef("%s = %s", k, v); // prints location of contacts (because of ["l"] argument above)
}
}
writeln("Done");
assert(!auther.check("non valid user", "non valid password"));
assert(auther.check("admin", ""));
```