Commit 4ea58bba authored by Jakob Moser's avatar Jakob Moser
Browse files

Add section on getting distinguished names

parent c9a9f1b0
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -52,6 +52,26 @@ user = input("Username: ")
password = getpass()
```

## Get distinguished name

The `user` name given above is what ldap calls the “common name” (CN). Together with a path in the LDAP directory, we can build the “distinguished name” (DN). The DN is used to uniquely identify the user, so we need it quite often.

```python
from ldap3.utils.dn import escape_rdn
```

### CL account

```python
dn = f"cn={escape_rdn(user)},ou=accounts,dc=cl,dc=uni-heidelberg,dc=de"
```

### Uni ID

```python
dn = f"cn={escape_rdn(user)},ou=fnphi,ou=rzuser,dc=ad,dc=uni-heidelberg,dc=de"
```

## Further reading

* [`portal/ldap/Directory.py`](https://gitlab.cl.uni-heidelberg.de/fachschaft/portal/-/blob/master/ldap/Directory.py?ref_type=heads): LDAP implementation for another project from which I self-plagiarized many of the instructions here