Hallo, I use OpenLDAP 2.4.19 and I try to build an own gender attribute.
I need a custom syntax for the value, "M" or "W".
I cannot find a description for ldapsyntax, I only find an example and I try this:
attributetype ( 1.3.6.1.4.1.xxxxxx.2.2.4.4 NAME ( 'gender' 'sex' ) DESC 'Gender: M for male, F for female' SYNTAX 1.3.6.1.4.1.xxxxxx.2.2.5.1 SINGLE-VALUE )
ldapsyntax ( 1.3.6.1.4.1.xxxxxx.2.2.5.1 NAME 'GenderType' DESC 'Case Insensitive Gender Type' X-VALIDATE-RE '^(?i)M|W|m|w$' )
but I think X-VALIDATE-RE is an extension for another LDAP-Server not for OpenLDAP because it does not work:
[LDAP: error code 21 - gender: no validator for syntax 1.3.6.1.4.1.xxxxxx.2.2.5.1]
How can I create my own custom syntax?
Thanks for any hints.
Ciao Peter Schütt
Peter Schütt wrote:
I use OpenLDAP 2.4.19 and I try to build an own gender attribute.
Why not use existing suggestions?
I need a custom syntax for the value, "M" or "W".
With OpenLDAP you don't need an extra syntax. You could use slapo-constraint for restricting attribute values. See the man-page slapo-constraint(5).
How can I create my own custom syntax?
An own LDAP syntax requires coding something which runs inside slapd (e.g. an overlay).
Ciao, Michael.
Peter SchÃŒtt wrote:
I use OpenLDAP 2.4.19 and I try to build an own gender attribute.
Why not use existing suggestions?
I need a custom syntax for the value, "M" or "W".
With OpenLDAP you don't need an extra syntax. You could use slapo-constraint for restricting attribute values. See the man-page slapo-constraint(5).
How can I create my own custom syntax?
An own LDAP syntax requires coding something which runs inside slapd (e.g. an overlay).
Actually, it would be much simpler than an overlay: all one needs to do is write a module that loads a syntax with its own handlers for validation and prettification. This means writing code that needs to be maintained, though. A simpler approach would be to use the boolean syntax, with an attribute that basically contains "isFemale"; then TRUE and FALSE would have a straightforward meaning (in a two-gender world, of course).
Or, one could use directoryString and restrict the value using slapo-constraint(5); something like
constraint_attribute sex regex "^[MW]$"
should work (untested, though).
p.
Hallo
I use OpenLDAP 2.4.19 and I try to build an own gender attribute.
With OpenLDAP you don't need an extra syntax. You could use slapo-constraint for restricting attribute values. See the man-page slapo-constraint(5).
This works, thank you.
Can I specify this constraint in the schema or can I only specify it in the slapd.conf or cn=config ?
Ciao Peter Schütt
openldap-technical@openldap.org