private static void modifyAttribute(String userName,LdapContext ctx,DirContext dircontxet,SearchControls searchControls) {
try {
NamingEnumeration<SearchResult> results = ctx.search("dc=germany,dc=pepsi,dc=jp", "uid=" + userName, searchControls);
String name ="uid=aman.sahu,cn=users,cn=accounts,dc=germany,dc=pepsi,dc=jp";
Attributes orig = ctx.getAttributes(name, new String[] { "gidNumber","cn" });
ModificationItem[] mods = new ModificationItem[2];
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute("displayName", "Aman Kumar Sahu"));
mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute("userPassword", "aman@8989"));
ctx.modifyAttributes(name, mods);
System.out.println("ATTRvalues"+ctx.getAttributes(name));
}
catch (NamingException n) {
n.printStackTrace();
}
}
我正在使用该用户的dn更新用户的属性,但我想使用该用户的UPN更新属性
答案 0 :(得分:0)
LDAP操作要求您仅按条目的DN引用条目。