2 .\" Copyright (C) 1990, Regents of the University of Michigan. All Rights Reserved.
3 .\" Portions Copyright (C) 2002, Sun Microsystems, Inc. All Rights Reserved.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH LDAP_DISPTMPL 3LDAP "Jan 27, 2002"
9 ldap_disptmpl, ldap_init_templates, ldap_init_templates_buf,
10 ldap_free_templates, ldap_first_disptmpl, ldap_next_disptmpl, ldap_oc2template,
11 ldap_name2template, ldap_tmplattrs, ldap_first_tmplrow, ldap_next_tmplrow,
12 ldap_first_tmplcol, ldap_next_tmplcol \- LDAP display template functions
16 cc[ \fIflag\fR... ] \fIfile\fR... -lldap[ \fIlibrary\fR... ]
20 \fBint\fR \fBldap_init_templates\fR(\fBchar\fR \fI*file\fR, \fBstruct ldap_disptmpl\fR \fI**tmpllistp\fR);
25 \fBint\fR \fBldap_init_templates_buf\fR(\fBchar\fR \fI*buf\fR, \fBunsigned long\fR \fIlen\fR,
26 \fBstruct ldap_disptmpl\fR \fI**tmpllistp\fR);
31 \fBvoid\fR \fBldap_free_templates\fR(\fBstruct ldap_disptmpl\fR \fI*tmpllist\fR);
36 \fBstruct ldap_disptmpl\fR \fB*ldap_first_disptmpl\fR
37 (\fBstruct ldap_disptmpl\fR \fI*tmpllist\fR);
42 \fBstruct ldap_disptmpl\fR \fB*ldap_next_disptmpl\fR
43 (\fBstruct ldap_disptmpl\fR \fI*tmpllist\fR,\fBstruct ldap_disptmpl\fR \fI*tmpl\fR);
48 \fBstruct ldap_disptmpl\fR \fB*ldap_oc2template\fR (\fBchar\fR \fI**oclist\fR,
49 \fBstruct ldap_disptmpl\fR \fI*tmpllist\fR);
54 \fBstruct ldap_disptmpl\fR \fB*ldap_name2template\fR (\fBchar\fR \fI*name\fR,
55 \fBstruct ldap_disptmpl\fR \fI*tmpllist\fR);
60 \fBchar\fR \fB**ldap_tmplattrs\fR(\fBstruct ldap_disptmpl\fR \fI*tmpl\fR, \fBchar\fR \fI**includeattrs\fR,
61 \fBint\fR \fIexclude;\fR, \fBunsigned long\fR \fIsyntaxmask\fR);
66 \fBstruct ldap_tmplitem\fR \fB*ldap_first_tmplrow\fR(\fBstruct ldap_disptmpl\fR \fI*tmpl\fR);
71 \fBstruct ldap_tmplitem\fR \fB*ldap_next_tmplrow\fR(\fBstruct ldap_disptmpl\fR \fI*tmpl\fR,
72 \fBstruct ldap_tmplitem\fR \fI*row\fR);
77 \fBstruct ldap_tmplitem\fR \fB*ldap_first_tmplcol\fR(\fBstruct ldap_disptmpl\fR \fI*tmpl\fR,
78 \fBstruct ldap_tmplitem\fR \fI*row\fR, \fBstruct ldap_tmplitem\fR \fI*col\fR);
83 \fBstruct ldap_tmplitem\fR \fB*ldap_next_tmplcol\fR(\fBstruct ldap_disptmpl\fR \fI*tmpl\fR,
84 \fBstruct ldap_tmplitem\fR \fI*row\fR, \fBstruct ldap_tmplitem\fR \fI*col\fR);
90 These functions provide a standard way to access LDAP entry display templates.
91 Entry display templates provide a standard way for LDAP applications to display
92 directory entries. The general idea is that it is possible to map the list of
93 object class values present in an entry to an appropriate display template.
94 Display templates are defined in a configuration file. See
95 \fBldaptemplates.conf\fR(4). Each display template contains a pre-determined
96 list of items, where each item generally corresponds to an attribute to be
97 displayed. The items contain information and flags that the caller can use to
98 display the attribute and values in a reasonable fashion. Each item has a
99 syntaxid, which are described in the SYNTAX IDS section below. The
100 \fBldap_entry2text\fR(3LDAP) functions use the display template functions and
104 \fBldap_init_templates()\fR reads a sequence of templates from a valid LDAP
105 template configuration file (see \fBldaptemplates.conf\fR(4)). Upon success,
106 \fB0\fR is returned, and \fItmpllistp\fR is set to point to a list of
107 templates. Each member of the list is an \fBldap_disptmpl\fR structure
108 (defined below in the DISPTMPL Structure Elements section).
111 \fBldap_init_templates_buf()\fR reads a sequence of templates from \fIbuf\fR
112 (whose size is \fIbuflen).\fR \fIbuf\fR should point to the data in the format
113 defined for an LDAP template configuration file (see
114 \fBldaptemplates.conf\fR(4)). Upon success, \fB0\fR is returned, and
115 \fItmpllistp\fR is set to point to a list of templates.
118 The \fBLDAP_SET_DISPTMPL_APPDATA()\fR macro is used to set the value of the
119 \fBdt_appdata\fR field in an \fBldap_disptmpl\fR structure. This field is
120 reserved for the calling application to use; it is not used internally.
123 The \fBLDAP_GET_DISPTMPL_APPDATA()\fR macro is used to retrieve the value in
124 the \fBdt_appdata\fR field.
127 The \fBLDAP_IS_DISPTMPL_OPTION_SET()\fR macro is used to test a
128 \fBldap_disptmpl\fR structure for the existence of a template option. The
129 options currently defined are: \fBLDAP_DTMPL_OPT_ADDABLE\fR (it is appropriate
130 to allow entries of this type to be added), \fBLDAP_DTMPL_OPT_ALLOWMODRDN\fR
131 (it is appropriate to offer the "modify rdn"operation),
132 \fBLDAP_DTMPL_OPT_ALTVIEW\fR (this template is merely an alternate view of
133 another template, typically used for templates pointed to be an
134 \fBLDAP_SYN_LINKACTION\fR item).
137 \fBldap_free_templates()\fR disposes of the templates allocated by
138 \fBldap_init_templates()\fR.
141 \fBldap_first_disptmpl()\fR returns the first template in the list
142 \fItmpllist.\fR The \fItmpllist\fR is typically obtained by calling
143 \fBldap_init_templates()\fR \fB\&.\fR
146 \fBldap_next_disptmpl()\fR returns the template after \fItmpl\fR in the
147 template list \fItmpllist.\fR \fIA\fR \fINULL\fR pointer is returned if
148 \fItmpl\fR is the last template in the list.
151 \fBldap_oc2template()\fR searches \fItmpllist\fR for the best template to use
152 to display an entry that has a specific set of \fBobjectClass\fR values.
153 \fIoclist\fR should be a null-terminated array of strings that contains the
154 values of the \fBobjectClass\fR attribute of the entry. A pointer to the
155 first template where all of the object classes listed in one of the template's
156 \fBdt_oclist\fR elements are contained in \fIoclist\fR is returned. A
157 \fINULL\fR pointer is returned if no appropriate template is found.
160 \fBldap_tmplattrs()\fR returns a null-terminated array that contains the names
161 of attributes that need to be retrieved if the template \fItmpl\fR is to be
162 used to display an entry. The attribute list should be freed using
163 \fBldap_value_free\fR(\|). The \fIincludeattrs\fR parameter contains a
164 null-terminated array of attributes that should always be included (it may be
165 \fINULL\fR if no extra attributes are required). If \fIsyntaxmask\fR is
166 non-zero, it is used to restrict the attribute set returned. If \fIexclude\fR
167 is zero, only attributes where the logical \fBAND\fR of the template item
168 syntax id and the \fIsyntaxmask\fR is non-zero are included. If \fIexclude\fR
169 is non-zero, attributes where the logical \fBAND\fR of the template item
170 syntax id and the \fIsyntaxmask\fR is non-zero are excluded.
173 \fBldap_first_tmplrow()\fR returns a pointer to the first row of items in
177 \fBldap_next_tmplrow()\fR returns a pointer to the row that follows \fIrow\fR
178 in template \fItmpl.\fR
181 \fBldap_first_tmplcol()\fR returns a pointer to the first item (in the first
182 column) of row \fIrow\fR within template \fItmpl\fR. A pointer to an
183 \fBldap_tmplitem\fR structure (defined below in the TMPLITEM Structure Elements
184 section) is returned.
187 The \fBLDAP_SET_TMPLITEM_APPDATA()\fR macro is used to set the value of the
188 \fBti_appdata\fR field in a \fBldap_tmplitem\fR structure. This field is
189 reserved for the calling application to use; it is not used internally.
192 The \fBLDAP_GET_TMPLITEM_APPDATA()\fR macro is used to retrieve the value of
193 the \fBti_appdata\fR field.
196 The \fBLDAP_IS_TMPLITEM_OPTION_SET()\fR macro is used to test a
197 \fBldap_tmplitem\fR structure for the existence of an item option. The options
198 currently defined are: \fBLDAP_DITEM_OPT_READONLY\fR (this attribute should not
199 be modified), \fBLDAP_DITEM_OPT_SORTVALUES\fR (it makes sense to sort the
200 values), \fBLDAP_DITEM_OPT_SINGLEVALUED\fR (this attribute can only hold a
201 single value), \fBLDAP_DITEM_OPT_VALUEREQUIRED\fR (this attribute must contain
202 at least one value), \fBLDAP_DITEM_OPT_HIDEIFEMPTY\fR (do not show this item if
203 there are no values), and \fBLDAP_DITEM_OPT_HIDEIFFALSE\fR (for boolean
204 attributes only: hide this item if the value is \fBFALSE\fR).
207 \fBldap_next_tmplcol()\fR returns a pointer to the item (column) that follows
208 column \fBcol\fR within row \fIrow\fR of template \fItmpl.\fR
209 .SS "DISPTMPL Structure Elements"
212 The \fBldap_disptmpl\fR structure is defined as:
216 struct ldap_disptmpl {
220 unsigned long dt_options;
221 char *dt_authattrname;
222 char *dt_defrdnattrname;
223 char *dt_defaddlocation;
224 struct ldap_oclist *dt_oclist;
225 struct ldap_adddeflist *dt_adddeflist;
226 struct ldap_tmplitem *dt_items;
228 struct ldap_disptmpl *dt_next;
236 The \fBdt_name\fR member is the singular name of the template. The
237 \fBdt_pluralname\fR is the plural name. The \fBdt_iconname\fR member will
238 contain the name of an icon or other graphical element that can be used to
239 depict entries that correspond to this display template. The \fBdt_options\fR
240 contains options which may be tested using the
241 \fBLDAP_IS_TMPLITEM_OPTION_SET()\fR macro.
244 The \fBdt_authattrname\fR contains the name of the DN-syntax attribute whose
245 value(s) should be used to authenticate to make changes to an entry. If
246 \fBdt_authattrname\fR is \fINULL\fR, then authenticating as the entry itself is
247 appropriate. The \fBdt_defrdnattrname\fR is the name of the attribute that is
248 normally used to name entries of this type, for example, "cn"for person
249 entries. The \fBdt_defaddlocation\fR is the distinguished name of an entry
250 below which new entries of this type are typically created (its value is
254 \fBdt_oclist\fR is a pointer to a linked list of object class arrays, defined
260 char **oc_objclasses;
261 struct ldap_oclist *oc_next;
268 These are used by the \fBldap_oc2template()\fR function.
271 \fBdt_adddeflist\fR is a pointer to a linked list of rules for defaulting the
272 values of attributes when new entries are created. The \fBldap_adddeflist\fR
273 structure is defined as:
277 struct ldap_adddeflist {
281 struct ldap_adddeflist *ad_next;
288 The ad_attrname member contains the name of the attribute whose value this rule
289 sets. If \fBad_source\fR is \fBLDAP_ADSRC_CONSTANTVALUE\fR then the
290 \fBad_value\fR member contains the (constant) value to use. If
291 \fBad_source\fR is \fBLDAP_ADSRC_ADDERSDN\fR then ad_value is ignored and the
292 distinguished name of the person who is adding the new entry is used as the
293 default value for \fBad_attrname\fR.
294 .SS "TMPLITEM Structure Elements"
297 The \fBldap_tmplitem\fR structure is defined as:
301 struct ldap_tmplitem {
302 unsigned long ti_syntaxid;
303 unsigned long ti_options;
307 struct ldap_tmplitem *ti_next_in_row;
308 struct ldap_tmplitem *ti_next_in_col;
317 Syntax ids are found in the \fBldap_tmplitem\fR structure element
318 \fBti_syntaxid\fR, and they can be used to determine how to display the values
319 for the attribute associated with an item. The \fBLDAP_GET_SYN_TYPE()\fR
320 macro can be used to return a general type from a syntax id. The five general
321 types currently defined are: \fBLDAP_SYN_TYPE_TEXT\fR (for attributes that are
322 most appropriately shown as text), \fBLDAP_SYN_TYPE_IMAGE\fR (for JPEG or FAX
323 format images), \fBLDAP_SYN_TYPE_BOOLEAN\fR (for boolean attributes),
324 \fBLDAP_SYN_TYPE_BUTTON\fR (for attributes whose values are to be retrieved and
325 display only upon request, for example, in response to the press of a button,
326 a JPEG image is retrieved, decoded, and displayed), and
327 \fBLDAP_SYN_TYPE_ACTION\fR (for special purpose actions such as "search for the
328 entries where this entry is listed in the seeAlso attribute").
331 The \fBLDAP_GET_SYN_OPTIONS\fR macro can be used to retrieve an unsigned long
332 bitmap that defines options. The only currently defined option is
333 \fBLDAP_SYN_OPT_DEFER,\fR which (if set) implies that the values for the
334 attribute should not be retrieved until requested.
337 There are sixteen distinct syntax ids currently defined. These generally
338 correspond to one or more X.500 syntaxes.
341 \fBLDAP_SYN_CASEIGNORESTR\fR is used for text attributes which are simple
342 strings whose case is ignored for comparison purposes.
345 \fBLDAP_SYN_MULTILINESTR\fR is used for text attributes which consist of
346 multiple lines, for example, \fBpostalAddress\fR, \fBhomePostalAddress\fR,
347 \fBmultilineDescription\fR, or any attributes of syntax \fBcaseIgnoreList\fR.
350 \fBLDAP_SYN_RFC822ADDR\fR is used for case ignore string attributes that are
351 RFC-822 conformant mail addresses, for example, mail.
354 \fBLDAP_SYN_DN\fR is used for attributes with a Distinguished Name syntax, for
355 example, \fBseeAlso\fR.
358 \fBLDAP_SYN_BOOLEAN\fR is used for attributes with a boolean syntax.
361 \fBLDAP_SYN_JPEGIMAGE\fR is used for attributes with a jpeg syntax, for
365 \fBLDAP_SYN_JPEGBUTTON\fR is used to provide a button (or equivalent interface
366 element) that can be used to retrieve, decode, and display an attribute of jpeg
370 \fBLDAP_SYN_FAXIMAGE\fR is used for attributes with a photo syntax, for
371 example, Photo. These are actually Group 3 Fax (T.4) format images.
374 \fBLDAP_SYN_FAXBUTTON\fR is used to provide a button (or equivalent interface
375 element) that can be used to retrieve, decode, and display an attribute of
379 \fBLDAP_SYN_AUDIOBUTTON\fR is used to provide a button (or equivalent interface
380 element) that can be used to retrieve and play an attribute of audio syntax.
381 Audio values are in the "mu law" format, also known as "au" format.
384 \fBLDAP_SYN_TIME\fR is used for attributes with the UTCTime syntax, for
385 example, \fBlastModifiedTime\fR. The value(s) should be displayed in complete
386 date and time fashion.
389 \fBLDAP_SYN_DATE\fR is used for attributes with the UTCTime syntax, for
390 example, \fBlastModifiedTime\fR. Only the date portion of the value(s) should
394 \fBLDAP_SYN_LABELEDURL\fR is used for \fBlabeledURL\fR attributes.
397 \fBLDAP_SYN_SEARCHACTION\fR is used to define a search that is used to retrieve
398 related information. If \fBti_attrname\fR is not \fINULL\fR, it is assumed to
399 be a boolean attribute which will cause no search to be performed if its value
400 is \fBFALSE\fR. The \fBti_args\fR structure member will have four strings
401 in it: \fBti_args[\fR \fB0\fR \fB]\fR should be the name of an attribute whose
402 values are used to help construct a search filter or "-dn" is the distinguished
403 name of the entry being displayed should be used, \fBti_args[\fR \fB1\fR
404 \fB]\fR should be a filter pattern where any occurrences of "%v" are replaced
405 with the value derived from \fBti_args[ 0 ]\fR, \fBti_args[\fR \fB2\fR
406 \fB]\fR should be the name of an additional attribute to retrieve when
407 performing the search, and \fBti_args[\fR \fB3\fR \fB]\fR should be a
408 human-consumable name for that attribute. The \fBti_args[\fR \fB2\fR \fB]\fR
409 attribute is typically displayed along with a list of distinguished names when
410 multiple entries are returned by the search.
413 \fBLDAP_SYN_LINKACTION\fR is used to define a link to another template by name.
414 \fBti_args[\fR \fB0\fR \fB]\fR will contain the name of the display template to
415 use. The \fBldap_name2template()\fR function can be used to obtain a pointer
416 to the correct \fBldap_disptmpl\fR structure.
419 \fBLDAP_SYN_ADDDNACTION\fR and \fBLDAP_SYN_VERIFYDNACTION\fR are reserved as
420 actions but currently undefined.
424 The init template functions return \fBLDAP_TMPL_ERR_VERSION\fR if \fIbuf\fR
425 points to data that is newer than can be handled, \fBLDAP_TMPL_ERR_MEM\fR if
426 there is a memory allocation problem, \fBLDAP_TMPL_ERR_SYNTAX\fR if there is a
427 problem with the format of the templates buffer or file.
428 \fBLDAP_TMPL_ERR_FILE\fR is returned by \fBldap_init_templates\fR if the file
429 cannot be read. Other functions generally return \fINULL\fR upon error.
433 See \fBattributes\fR(5) for a description of the following attributes:
441 ATTRIBUTE TYPE ATTRIBUTE VALUE
442 Interface Stability Evolving
448 \fBldap\fR(3LDAP), \fBldap_entry2text\fR(3LDAP), \fBldaptemplates.conf\fR(4),