You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by david jones <jo...@gmail.com> on 2011/09/15 14:48:55 UTC

Is anything besides String supported for BasicAttribute?

Is anything besides String supported for BasicAttribute?

I'm using ApacheDS 1.5.

I tried adding a port value as an integer to schema:

dn: m-oid=1.3.6.1.4.1.18060.0.9.1.1.2.1.3, ou=attributeTypes, cn=other,
ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 1.3.6.1.4.1.18060.0.9.1.1.2.1.3
m-name: port
m-description: ip port
m-equality: integerMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.27 (Integer)


code:

....
attributes.put(new BasicAttribute("ipV4Addr", "10.0.0.1");
attributes.put(new BasicAttribute("port", intPort);
...
ctx.createSubcontext(cn, attributes);



Looking at the created entry with Studio: it got created with the IP address
attribute (string) , but not the port value (integer). I don't see any
errors in the ldap debug printouts.

If i change code to:
         attributes.put(new BasicAttribute("port", intPort.toString());
and the port's schema to:
     m-syntax: 1.3.6.1.4.1.1466.115.121.1.26 (IA5 String)

The port gets added. Is this expected behavior, or am I missing something in
my schema/code to allow non-String attribute values?


thanks,
David

Re: Is anything besides String supported for BasicAttribute?

Posted by Stefan Seelmann <se...@apache.org>.
Hi David,

Even if LDAP supports several syntaxes and matching rules, the
encoding of a value is mostly its string representation [1]. In your
case you can just use
    attributes.put(new BasicAttribute("port", Integer.toString(intPort));

HTH,
Stefan

[1] http://tools.ietf.org/html/rfc4517#section-3.3.16


On Thu, Sep 15, 2011 at 2:48 PM, david jones <jo...@gmail.com> wrote:
> Is anything besides String supported for BasicAttribute?
>
> I'm using ApacheDS 1.5.
>
> I tried adding a port value as an integer to schema:
>
> dn: m-oid=1.3.6.1.4.1.18060.0.9.1.1.2.1.3, ou=attributeTypes, cn=other,
> ou=schema
> objectclass: metaAttributeType
> objectclass: metaTop
> objectclass: top
> m-oid: 1.3.6.1.4.1.18060.0.9.1.1.2.1.3
> m-name: port
> m-description: ip port
> m-equality: integerMatch
> m-syntax: 1.3.6.1.4.1.1466.115.121.1.27 (Integer)
>
>
> code:
>
> ....
> attributes.put(new BasicAttribute("ipV4Addr", "10.0.0.1");
> attributes.put(new BasicAttribute("port", intPort);
> ...
> ctx.createSubcontext(cn, attributes);
>
>
>
> Looking at the created entry with Studio: it got created with the IP address
> attribute (string) , but not the port value (integer). I don't see any
> errors in the ldap debug printouts.
>
> If i change code to:
>         attributes.put(new BasicAttribute("port", intPort.toString());
> and the port's schema to:
>     m-syntax: 1.3.6.1.4.1.1466.115.121.1.26 (IA5 String)
>
> The port gets added. Is this expected behavior, or am I missing something in
> my schema/code to allow non-String attribute values?
>
>
> thanks,
> David
>