ldap.create-attribute

function

Library: LDAP support (OMLDAP)
Import : omldap.xmd

Declaration
define external ldap.attribute function ldap.create-attribute
    named       value  string  attribute-name
    of-type     value  integer datatype        optional
    with-values read-only stream  values

or

define external ldap.attribute function ldap.create-attribute
    named       value  string  attribute-name
    of-type     value  integer datatype        optional
    with-value  remainder string  value
      and ...

Argument definitions

attribute-name
The name of the attribute.
datatype
The type of the attribute. The default is ldap.text-type; the other option is ldap.binary-type.
values
A shelf of values to assign to the attribute. This is an alternative to specifying each value individually.
value
A list of values to assign to the attribute (separated by the word "and" if there is more than one). This is an alternative to specifying the values in a shelf.


Purpose

This function assigns value(s) to an ldap.attribute of an entry that you will add later with the ldap.add-entry function.

This example creates two attributes. The attribute "cn" (common name) contains multiple text values. The attribute "photo" contains a single binary value (the contents of a JPEG file).

  import "omldap.xmd" prefixed by ldap.
  
  process
     local ldap.connection my-ldap
     local ldap.attribute  my-entry variable
  
     set my-ldap to ldap.open 'www.stilo.com'
  
     set new my-entry to ldap.create-attribute named "cn"
        with-value "Brown" and "V. Brown" and "Valerie Brown"
  
     set new my-entry to ldap.create-attribute named "photo"
        of-type    ldap.binary-type
        with-value file "vbrown.jpg"
  
     ldap.add-entry my-ldap
        named "cn=Brown,Department=HR,o=OmniMark.com"
        attributes my-entry

In the example above, the attribute is "cn" and its three values are "Brown", " V. Brown" and "Valerie Brown".