• Stars
    star
    18
  • Rank 1,208,065 (Top 24 %)
  • Language
    Crystal
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Crystal lang LDAP client

LDAP Support for Crystal Lang

CI

Installation

Add the dependency to your shard.yml:

dependencies:
  ldap:
    github: spider-gazelle/crystal-ldap

Usage

Connecting and Binding

Passing a TLS context will upgrade the connection using start tls

require "ldap"

host = "ldap.forumsys.com"
port = 389
user = "cn=read-only-admin,dc=example,dc=com"
pass = "password"

# Standard LDAP port with unencrypted socket
socket = TCPSocket.new(host, port)

# Providing a context will upgrade to encrypted comms using start tls (official method)
tls = OpenSSL::SSL::Context::Client.new
tls.verify_mode = OpenSSL::SSL::VerifyMode::NONE

# Bind to the server
client = LDAP::Client.new(socket, tls)
client.authenticate(user, pass)

# Can now perform LDAP operations

To use the non-standard LDAPS (LDAP Secure, commonly known as LDAP over SSL) protocol then pass in a OpenSSL::SSL::Socket::Client directly: LDAP::Client.new(tls_socket)

# LDAPS method
socket = TCPSocket.new(host, port)
tls = OpenSSL::SSL::Context::Client.new
tls.verify_mode = OpenSSL::SSL::VerifyMode::NONE
socket = OpenSSL::SSL::Socket::Client.new(socket, context: tls, sync_close: true, hostname: host)

# Bind to the server
client = LDAP::Client.new(socket)
client.authenticate(user, pass)

# Can now perform LDAP operations

Querying

You can perform search requests

# You can use LDAP string filters directly
client.search(base: "dc=example,dc=com", filter: "(|(uid=einstein)(uid=training))")

# There are options to select particular attributes and limit response sizes
filter = LDAP::Request::Filter.equal("objectClass", "person")
client.search(
  base: "dc=example,dc=com",
  filter: filter,
  size: 6,
  attributes: ["hasSubordinates", "objectClass"]
)

# Filters can be combined using standard operations
filter = (
          LDAP::Request::Filter.equal("objectClass", "person") &
          LDAP::Request::Filter.equal("sn", "training")) |
          LDAP::Request::FilterParser.parse("(uid=einstein)"
         )
client.search(base: "dc=example,dc=com", filter: filter)

Search responses are Array(Hash(String, Array(String)))

[
 {
  "dn" => ["uid=einstein,dc=example,dc=com"],
  "objectClass" => ["inetOrgPerson", "organizationalPerson", "person", "top"],
  "cn" => ["Albert Einstein"],
  "sn" => ["Einstein"],
  "uid" => ["einstein"],
  "mail" => ["[email protected]"],
  "telephoneNumber" => ["314-159-2653"]
 },
 {
  "dn" => ["uid=training,dc=example,dc=com"],
  "uid" => ["training"],
  "objectClass" => ["inetOrgPerson", "organizationalPerson", "person", "top"],
  "cn" => ["FS Training"],
  "sn" => ["training"],
  "mail" => ["[email protected]"],
  "telephoneNumber" => ["888-111-2222"]
 }
]

More Repositories

1

spider-gazelle

A Rails esque web framework with a focus on speed and extensibility for crystal lang
Crystal
179
star
2

tasker

Scheduled tasks for crystal lang
Crystal
56
star
3

bindata

BinData - Parsing Binary Data in Crystal Lang
Crystal
48
star
4

ssh2.cr

libssh2 binding for Crystal language
Crystal
44
star
5

promise

Type aware promises for crystal lang
Crystal
42
star
6

action-controller

A rails-esque controller framework for crystal lang
Crystal
41
star
7

active-model

A rails-esque model framework for crystal lang
Crystal
28
star
8

rethinkdb-orm

RethinkDB ORM for Crystal lang
Crystal
24
star
9

crystal-mqtt

Crystal lang implementation of the MQTT protocol, a lightweight protocol for publish/subscribe messaging
Crystal
20
star
10

ffmpeg

ffmpeg crystal bindings
Crystal
19
star
11

qr-code

a QR Code implementation written in crystal lang
Crystal
17
star
12

crystal-snmp

SNMP implementation for crystal lang
Crystal
16
star
13

json-schema

Describe crystal-lang JSON serializable types with JSON Schema
Crystal
13
star
14

priority-queue

Priority Queue and Heap implementation for Crystal Lang
Crystal
13
star
15

bisect

Library for maintaining sorted Arrays
Crystal
12
star
16

pars

Parser combinator library for crystal-lang
Crystal
11
star
17

pinger

Microlibrary to perform ping requests with Crystal Lang
Crystal
11
star
18

telnet.cr

Telnet protocol helper for crystal lang
Crystal
11
star
19

crystal-openai

OpenAI ChatGPT, GPT-3, GPT-4, DALLยทE, Whisper API Client for Crystal
Crystal
11
star
20

pg-orm

Postgres ORM for Crystal Lang
Crystal
10
star
21

inactive-support

Utilities for crystal-lang
Crystal
10
star
22

mdns

Crystal Lang mDNS and DNS-SD Support
Crystal
8
star
23

tensorflow_lite

tensorflow lite bindings for crystal lang
Crystal
8
star
24

ed25519

Ed25519 high-performance public-key signature system for crystal lang
Crystal
7
star
25

secure-remote-password

Crystal implementation of the Secure Remote Password protocol (SRP-6a)
Crystal
7
star
26

crystal-gpt

ChatGPT plugin template that allows you to focus on writing actions, automatically generating the required metadata
Crystal
7
star
27

connect-proxy

crystal lang connect / HTTP proxy implementation
Crystal
7
star
28

simple_retry

a tool for retrying code blocks
Crystal
6
star
29

crunits

Physical quantity and units of measure conversion and math for crystal lang
Crystal
6
star
30

secrets-env

Extension to the crystal lang ENV module to support reading secrets
Crystal
6
star
31

v4l2.cr

crystal lang video for linux device helpers / bindings
Crystal
5
star
32

log_helper

Extension for Crystal Log to aid logging key-value data
Crystal
5
star
33

cmac

Crystal implementation of the Cipher-based Message Authentication Code (CMAC)
Crystal
5
star
34

readers-writer

A simple readers writer lock for crystal lang
Crystal
5
star
35

worker_pool

a basic fiber pool implementation for crystal lang
Crystal
5
star
36

matter

A complete Crystal implementation of the Matter protocol specification (https://buildwithmatter.com). Includes full support for controller, device, commissioning, secure communications, device types, and cluster definitions.
Crystal
5
star
37

guide

Spider Gazelle Documentation
Python
4
star
38

ntlm

NTLM authentication for crystal lang
Crystal
4
star
39

digest-auth

HTTP digest auth for crystal lang
Crystal
4
star
40

eventbus

Listen for Postgres database change events and publish them to event listeners
Crystal
3
star
41

knx

KNX protocol support for crystal lang
Crystal
3
star
42

tokenizer

Simplified binary stream tokenization for crystal lang
Crystal
2
star
43

crystal-dtls

DTLS support for crystal lang
Crystal
2
star
44

stumpy_resize

resizes stumpy canvas images in pure crystal
Crystal
2
star
45

upload-signer

Provide API for generating pre-signed URLs for file uploads to cloud storage
Crystal
2
star
46

SPAKE2_plus

a crystal lang implementation of SPAKE2+, a Password Authenticated Key Exchange (PAKE) protocol
Crystal
2
star
47

stomp

crystal lang implementation of the STOMP protocol
Crystal
1
star
48

tlv

Matter TLV encoder/decoder
Crystal
1
star
49

gpio.cr

crystal lang bindings for linux gpiod
Crystal
1
star
50

HKDF

HMAC-based Extract-and-Expand Key Derivation Function (HKDF) for crystal lang
Crystal
1
star
51

panopticon

Distributed tracing for services built in crystal-lang
Crystal
1
star
52

tflite_image

image classification and feature detection with tflite and crystal lang
Crystal
1
star
53

tflite_pipeline

video processing AI pipeline leveraging tflite_image
Crystal
1
star
54

link-header

Crystal Lang HTTP Link Header Parser
Crystal
1
star