Skip to content

Commit f99b8a0

Browse files
author
chaoflow
committed
ldap.rst
git-svn-id: https://svn.plone.org/svn/collective/bda.ldap/trunk@122119 db7f04ef-aaf3-0310-a811-c281ed44c4ad
1 parent f81d059 commit f99b8a0

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

ldap.rst

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
LDAP
2+
====
3+
4+
LDAP in general
5+
---------------
6+
7+
ldap is hierarhical, every node is uniquely identified via a
8+
distinguished name (dn) and every node can be a leave or the root (base)
9+
for another subtree. Among siblings a leave is uniquely identified by
10+
the relative distinguished name (rdn). In general an rdn looks like
11+
``<attr_name>=<attr_value>``, but may also be composed of multiple such
12+
pairs joined by '+'.::
13+
14+
# base of all bases, also named base dn
15+
dn: dc=my-domain,dc=com
16+
objectClass: top
17+
objectClass: dcObject
18+
objectClass: organization
19+
o: my-organization
20+
dc: my-domain
21+
22+
dn: ou=customers,dc=my-domain,dc=com
23+
ou: customers
24+
objectClass: top
25+
objectClass: organizationalUnit
26+
27+
dn: ou=customer1,ou=customers,dc=my-domain,dc=com
28+
ou: customer1
29+
objectClass: top
30+
objectClass: organizationalUnit
31+
32+
dn: ou=customer2,ou=customers,dc=my-domain,dc=com
33+
ou: customer2
34+
objectClass: top
35+
objectClass: organizationalUnit
36+
37+
In Zope/Plone terminology every node is a container that has attributes
38+
and child nodes. objectclasses define what attributes a node must and
39+
may have, similar to zope schema interfaces. objectclasses supplement
40+
(subclass) other objectclasses, the root of all being ``top``.
41+
42+
LDAP Schema (in contrast to zope schemas) define what objectClasses and
43+
attributetypes an ldap server knows about, attributetypes define valid
44+
values for attributes, whether they are case sensitive, binary, how
45+
values are compared, ... .
46+
47+
To search an ldap directory, you specify a baseDN, scope and filter
48+
- baseDN, where to start the search
49+
- scope, how far to go, BASE (only the baseDN itself), ONELEVEL (direct child
50+
nodes of the baseDN), SUBTREE (everything beneath the baseDN)
51+
- filter, what nodes to match, the default is '(objectClass=*)', which matches
52+
all nodes (more on this below)
53+
54+
Recent LDAP implementations all support querying the known schemas via ldap,
55+
they could be used and translated to zope schemas.
56+
57+
58+
LDAP Users
59+
----------
60+
61+
In order for a node to qualify as an ldap user, it only needs to have a
62+
``userPassword`` attribute. The username is the dn, and the password hash is
63+
stored as the ``userPassword`` attribute value. As the password is hashed, in
64+
order to authenticate a user the dn and plain-text password are passed to
65+
``bind(userdn, password)``.
66+
67+
A user can be anywhere in the ldap tree. In order to produce a listing of
68+
valid users, sane ldap layouts use a dedicated objectClass to identify users,
69+
e.g. inetOrgPerson. The existence of a userPassword attribute does not suffice,
70+
as pure system accounts, e.g. the manager dn for the ldap directory also has
71+
one.
72+
73+
ActiveDirectory, being in my personal opinion on the border of sane
74+
implementations, to say the best, has an ``objectClass: computer`` that
75+
supplements ``user``, i.e. all computers are users. If you combine that with
76+
two logon domains in one ActiveDirectory, the filters get really messy.
77+
However, they have objectCategory and there is normally a group of which all
78+
real users are members.
79+
80+
81+
LDAP Groups
82+
-----------
83+
84+
There are (at least) three concepts to model groups in ldap.
85+
86+
1. dedicated node, ``objectClass: groupOfNames`` (openldap), all information on
87+
the group node, the user node does not store information, user node is
88+
arbitrary::
89+
90+
dn: cn=group1,dc=my-domain,dc=com
91+
cn: group1
92+
objectClass: top
93+
objectClass: groupOfNames
94+
member: <dn of user or group (even an arbitrary node?)>
95+
member: <dn of user or group (even an arbitrary node?)>
96+
member: <dn of user or group (even an arbitrary node?)>
97+
98+
2. mixture, ``objectClass: posixGroup`` (OpenDirectory and openldap nis.schema),
99+
membership information on the user node, group name on the group node, only
100+
user nodes with ``objectClass: posixAccount``::
101+
102+
dn: cn=group2,dc=my-domain,dc=com
103+
cn: group2
104+
objectClass: top
105+
objectClass: posixGroup
106+
gidNumber: 42
107+
108+
dn: uid=user1,dc=my-domain,dc=com
109+
uid: user1
110+
objectClass: top
111+
objectClass: posixAccount
112+
uidNumber: 17
113+
gidNumber: 42
114+
homeDirectory: /home/user1
115+
116+
Note: The schemas do not define which attribute is used for the RDN, it is up
117+
to the ldap directory layout, the only condition is: it must be unique among
118+
its siblings.
119+
120+
Note: At least for openldap nis schema the homeDirectory is required, I just
121+
put it there so I can use those entries later on for testing.
122+
123+
3. redundant, ``objectClass: group`` (ActiveDirectory), membership information
124+
on the group and on the user::
125+
126+
dn: cn=group3,dc=my-domain,dc=com
127+
cn: group3
128+
objectClass: top
129+
objectClass: group
130+
member: <dn of user or group (even an arbitrary node?)>
131+
member: <dn of user or group (even an arbitrary node?)>
132+
member: <dn of user or group (even an arbitrary node?)>
133+
134+
dn: cn=user2,dc=my-domain,dc=com
135+
cn: user2
136+
objectClass: top
137+
objectClass: person
138+
objectClass: organizationalPerson
139+
objectClass: user
140+
memberOf: cn=group3,dc=my-domain,dc=com
141+
142+
143+
All have in common that a group can be anywhere in ldap tree. But in general
144+
they can be uniquely identified by objectClass.
145+
146+
For further reading: http://www.zytrax.com/books/ldap/

0 commit comments

Comments
 (0)