[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
RE: Java + LDAP
Hi,
you have to read the existing values, add the new one and modify:
Attributes attributes =
ctx.getAttributes(ldapName);
Attribute aValues = attributes.get
("groupId");
aValues.add(value); // value is the
new value
ctx.modifyAttributes (ldapName,
DirContext.REPLACE_ATTRIBUTE, attributes);
regards
Martin
-----Original Message-----
From: Zamangoer, Ferruh [mailto:ferruh.zamangoer@materna.de]
Sent: Friday, May 24, 2002 12:29
To: openldap-software@OpenLDAP.org
Subject: Java + LDAP
Hi all,
I have defined in my schema a multivalued attribute groupId. I have the
following Problem:
groupId: 2
groupId: 3
groupId: 4
groupId: 5
groupId: 6
This is only one attribute which holds many values . But when I want to use
the modify method from JNDI like this
<code-snip>
Hashtable env = new Hashtable();
env = setEnviroment(aHypLdapModifyTrans.getLdapUsername(),
aHypLdapModifyTrans.getLdapPassword());
DirContext ctx = new InitialDirContext(env);
ModificationItem[] mods = new ModificationItem[1];
mods[0] = new
ModificationItem(aHypLdapModifyTrans.getModificationType(),
new BasicAttribute(aHypLdapModifyTrans.getAttributeName(),new
String(aHypLdapModifyTrans.getAttributeValue())));
ctx.modifyAttributes(aHypLdapModifyTrans.getDistinguishedName(),
mods);
ctx.close();
<code-snip>
I overwrite my existing multivalued Attribute . How can I solve them that I
can only change one values in the multivalued Attribute.
I have seen in many tools it is possible to change one value without to
delete the mutlivalued Attribute .
Thanks for any help in advance
Regards
Ferruh