Skip to content

Commit d1df9a3

Browse files
authored
chore(readme): add LDAPS connection example
1 parent 1cc8d0d commit d1df9a3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ client.authenticate(user, pass)
4242

4343
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)`
4444

45+
```crystal
46+
# LDAPS method
47+
socket = TCPSocket.new(host, port)
48+
tls = OpenSSL::SSL::Context::Client.new
49+
tls.verify_mode = OpenSSL::SSL::VerifyMode::NONE
50+
socket = OpenSSL::SSL::Socket::Client.new(socket, context: tls, sync_close: true, hostname: host)
51+
52+
# Bind to the server
53+
client = LDAP::Client.new(socket)
54+
client.authenticate(user, pass)
55+
56+
# Can now perform LDAP operations
57+
```
58+
59+
4560
### Querying
4661

4762
You can perform search requests

0 commit comments

Comments
 (0)