Commit 3f93f872 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add server object creation

parent 4f74e2de
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -9,3 +9,29 @@ uv run --with=ldap3 --python 3.12 python
```
>>>

## Available LDAP servers

| Name | URL | Account type |
|------|-----|--------------|
| Institut für Computerlinguistik | `ldaps://ldap2.cl.uni-heidelberg.de` | CL account |
| Universität Heidelberg | `ldaps://ad.uni-heidelberg.de` | Uni ID |


## Create server object

```python
import ssl
from ldap3 import Tls, Server

TLS_CONFIGURATION = Tls(validate=ssl.CERT_REQUIRED)

ldap_server_url = ...  # Choose one from the table above
server = Server(ldap_server_url, use_ssl=True, tls=TLS_CONFIGURATION)
```

>>> [!note]

The URL scheme (`ldap://` or `ldaps://`) has precedence over the parameter `use_ssl` (see https://ldap3.readthedocs.io/en/latest/server.html). This means that the parameter is superfluous if you specify a URL scheme.

However, setting it to true means that if there ever is a case where no scheme is specified, the connection will fall back to use SSL, and I believe that is a good way for things to be.
>>>