After a search in LDAP, written in Java, I have a valid entry as
cn=DE9-M5T,ou=students,ou=users,o=data
When I now do
if (entry != null && entry.getAttribute("modifyTimestamp") != null) {
String dn = entry.getDN();
String modifyTimestamp = entry.getAttribute("modifyTimestamp").getStringValue();
String oldTimestamp = modificationTimestampCache.get(dn);
String cnUserId = entry.getAttribute("cn").getStringValue();
...
}
the last line gives a NullPointerException, which means that
entry.getAttribute("cn")
must return null
. Following the documentation, this would only happen if the given attribute (here "cn"
) could not be found as exact match. Is there any reason that this could happen for "cn"
in LDAP?
From your code I can't figure out the exact types of your entry and its getAttribute(), but consider this:
cn
is a multivalued ldap attribute, where modifytimestamp
is single valued.
So, the values of cn
are probably stored in an array-like structure, I guess that your getAttribute() does not handle this as you expect.
Not every object class has a cn
attribute. Only those where it appears in the schema.
Evidently this isn't one of them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.