-1

I am creating an application where I am write LDAP client which would connect to SunOne Directory Server. User an enter attributes, select type and enter value and my application will create that user on the SunOne.

When user selects homePhone, type as Integer and enters value as 22334546, it fails with below exception

javax.naming.directory.InvalidAttributeValueException: Malformed 'homePhone' attribute value; remaining name 'cn=Identity3,ou=SunOU'

The code for same is

for(...)
{
  String attrName = attrRequest.getName();
  Object attrVal = attrRequest.getValue();
  BasicAttribute attribute = getBasicAttribute(attrName, attrVal);
  attrs.put(attribute);
}

ldapCtx.bind(objectDN,null,attrs);

I am able to create this user using Apache directory Studio

enter image description here

user207421
  • 305,947
  • 44
  • 307
  • 483
SimpleGuy
  • 2,764
  • 5
  • 28
  • 45

1 Answers1

0

Generally, a phone number is a string, not an integer. RFC 4517 recommends to store phone numbers in a canonical format - i.e. E.123 international. The "Telephone Number" syntax for attribute homePhone is configured in your LDAP schema and is enforced by default - you can alter the configuration, though.

If your own Java program and Apache Directory Studio connect to the same LDAP server instance, they should be treated the same, because syntax is enforced by the server and not by the client. And since 22334546 is an acceptable value, Apache Directory Studio succeeds.

The error seems to be with your code, mainly attrVal not holding the right value.

Community
  • 1
  • 1
marabu
  • 1,166
  • 7
  • 9