File: slapd-tcl.5

package info (click to toggle)
openldap2.2 2.2.23-8
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 15,936 kB
  • ctags: 11,357
  • sloc: ansic: 145,319; sh: 17,543; cpp: 4,178; sql: 1,566; makefile: 1,284; perl: 744
file content (271 lines) | stat: -rw-r--r-- 7,528 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
.TH SLAPD-TCL 5 "RELEASEDATE" "OpenLDAP LDVERSION"
.\" $OpenLDAP: pkg/ldap/doc/man/man5/slapd-tcl.5,v 1.7 2003/01/09 11:07:14 kurt Exp $
.SH NAME
slapd-tcl \- Tcl backend to slapd
.SH SYNOPSIS
ETCDIR/slapd.conf
.SH DESCRIPTION
The Tcl backend to
.BR slapd (8)
works by embedding a
.BR Tcl (3tcl)
interpreter into
.BR slapd (8).
Any tcl database section of the configuration file
.BR slapd.conf (5)
must then specify what Tcl script to use.
.LP
This backend is experimental.
.SH WARNING
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
Previously, the 2nd argument to the procs was a message ID.
Now they are an "operation ID" string.
Also, proc abandon now gets a new
.B abandonid
argument.
.SH CONFIGURATION
These
.B slapd.conf
options apply to the TCL backend database.
That is, they must follow a "database tcl" line and come before any
subsequent "backend" or "database" lines.
Other database options are described in the
.BR slapd.conf (5)
manual page.
.TP
.B scriptpath      <filename.tcl>
The full path to the tcl script used for this database.
.LP
.B search   <proc>
.br
.B add      <proc>
.br
.B delete   <proc>
.br
.B modify   <proc>
.br
.B bind     <proc>
.br
.B unbind   <proc>
.br
.B modrdn   <proc>
.br
.B compare  <proc>
.br
.B abandon  <proc>
.RS
The procs for each ldap function.
They refer to the tcl procs in the `scriptpath' script that handles them.
.RE
.TP
.B tclrealm <interpreter name>
This is one of the biggest pluses of using the tcl backend.
The realm lets you group several databases to the same interpreter.
This basically means they share the same global variables and proc space.
So global variables, as well as all the procs, are callable between databases.
If no tclrealm is specified, it is put into the "default" realm.
.SH Variables passed to the procs
.TP
.B abandon { action opid suffix abandonid }
.nf
action    - Always equal to ABANDON.
opid      - The opid of this ldap operation.
suffix    - List of suffix(es) associated with the
            call.  Each one is an entry in a tcl
            formatted list (surrounded by {}'s).
abandonid - The opid of the operation to abandon.
.fi
.TP
.B add "{ action opid suffix entry }"
.nf
action - Always equal to ADD.
opid   - The opid of this ldap operation.
suffix - List of suffix(es), as above.
entry  - Full entry to add. Each "type: val" is
         an element in a tcl formatted list.
.fi
.TP
.B bind "{ action opid suffix dn method cred_len cred }"
.nf
action   - Always equal to BIND.
opid     - The opid of this ldap operation.
suffix   - List of suffix(es), as above.
dn       - DN being bound to.
method   - One of the ldap authentication methods.
cred_len - Length of cred.
cred     - Credentials being used to authenticate,
           according to RFC.  If this value is empty,
           then it should be considered an anonymous
           bind (??)
.fi
.TP
.B compare "{ action opid suffix dn ava_type ava_value }"
.nf
action    - Always equal to COMPARE.
opid      - The opid of this ldap operation.
suffix    - List of suffix(es), as above.
dn        - DN for compare.
ava_type  - Type for comparison.
ava_value - Value to compare.
.fi
.TP
.B delete "{ action opid suffix dn }"
.nf
action    - Always equal to DELETE.
opid      - The opid of this ldap operation.
suffix    - List of suffix(es), as above.
dn        - DN to delete.
.fi
.TP
.B modify "{ action opid suffix dn mods }"
.nf
action - Always equal to MODIFY.
opid   - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn     - DN to modify.
mods   - Tcl list of modifications.
         The list is formatted in this way:

         {
           { {op: type} {type: val} }
           { {op: type} {type: val} {type: val} }
           ...
         }

         Newlines are not present in the actual var,
         they are present here for clarification.
         "op" is the type of modification
         (ADD, DELETE, REPLACE).
.fi
.TP
.B modrdn "{ action opid suffix dn newrdn deleteoldrdn }"
.nf
action - Always equal to MODRDN.
opid   - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn     - DN whose RDN is being renamed.
newrdn - New RDN.
deleteoldrdn - Boolean stating whether or not the
         old RDN should be removed after being renamed.
.fi
.TP
.B
search { action opid suffix base scope deref \
sizelimit timelimit filterstr attrsonly attrlist }
.nf
action    - Always equal to SEARCH.
opid      - The opid of this ldap operation.
suffix    - List of suffix(es), as above.
base      - Base for this search.
scope     - Scope of search, ( 0 | 1 | 2 ).
deref     - Alias dereferencing ( 0 | 1 | 2 | 3 ).
sizelimit - Maximum number of entries to return.
timelimit - Time limit for search.
filterstr - Filter string as sent by the requester.
attrsonly - Boolean for whether to list only the
            attributes, and not values as well.
attrlist  - Tcl list if to retrieve.
.fi
.TP
.B unbind "{ action opid suffix dn }"
.nf
action - Always equal to UNBIND.
opid   - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn     - DN to unbind.
.fi
.LP
An
.I opid
(operation ID) is a "connection ID/message ID" string identifying an
operation.
.LP
.SH Return Method and Syntax
There are only 2 return types.
All procs must return a result to show status of the operation.
The result is in this form:
.LP
.RS
.nf
{ RESULT {code: <integer>} {matched: <partialdn>}
  {info: <string>} {} }
.fi
.RE
.LP
This is best accomplished with this type of tcl code
.LP
.RS
.nf
  lappend ret_val "RESULT"
  lappend ret_val "code: 0"
  lappend ret_val ""
  return $ret_val
.fi
.RE
.LP
The final empty string (item in list) is necessary to point to the end
of list.
The `code', `matched', and `info' values are not necessary, and
default values are given if not specified.
The `code' value is usually an LDAP error in decimal notation from
ldap.h.
The `info', may be sent back to the client, depending on the
function.
In the bind proc, LDAP uses the value of `code' to indicate whether or
not the authentication is acceptable.
.LP
The other type of return is for searches.
It is similar format to the shell backend return (as is most of the
syntax here).
Its format follows:
.LP
.RS
.nf
{dn: o=Company, c=US} {attr: val} {objectclass: val} {}
{dn: o=CompanyB, c=US} {attr: val} {objectclass: val} {}
.fi
.RE
.LP
Again, newlines are for visual purposes here.
Also note the {} marking the end of the entry (same effect as a
newline in ldif format).
Here is some example code again, showing a full search proc example.
.LP
.RS
.nf
# Note that `args' lets you lump all possible args
# into one var, used here for simplicity of example
proc ldap:search { args } {
  # ...perform some operations...

  lappend ret_val "dn: $rdn,$base"
  lappend ret_val "objectclass: $objcl"
  lappend ret_val "sn: $rdn"
  lappend ret_val "mail: $email"
  lappend ret_val ""
  # Now setup the result
  lappend ret_val "RESULT"
  lappend ret_val "code: 0"
  lappend ret_val ""
  return $ret_val
}
.fi
.RE
.LP
NOTE: Newlines in the return value is acceptable in search entries
(i.e. when returning base64 encoded binary entries).
.LP
.SH Builtin Commands and Variables
.TP
.B ldap:debug <msg>
Allows you to send debug messages through OpenLDAP's native debugging
system, this is sent as a LDAP_DEBUG_ANY and will be logged.
Useful for debugging scripts or logging bind failures.
.SH FILES
.TP
ETCDIR/slapd.conf
default slapd configuration file
.SH SEE ALSO
.BR slapd.conf (5),
.BR slapd (8),
.BR Tcl (3tcl).