Hi, I created a class that validate an user in NDS, but I need to get the value of one NDS parameter (called "Company") of the respective user. How can I do this? Please, I really need some help here. Thanks.
I hope this isn't for a homework assignment. Here's some code that might help you:
"myCtx" is an instance of "DirContext". "attrName" and "attrValue" are attribute name and value you want to search by. For example, it could be "cn" and "jbrown". The attribute value can contain wild cards, etc., just standard LDAP stuff. "searchScope" is one of teh valid "SearchControls.XXXX" values (ONELEVEL_SCOPE, OBJECT_SCOPE, SUBTREE_SCOPE, ...). Again pretty standard LDAP stuff. In the example here it will retrieve all of the attributes from the matching object and save the key/value pairs in a "TreeMap". It only handles String (text) attribute values nicely, and it doesn't have allowance for multi-value attributes. I'm sure you can add those if you need. It is fairly easy to modify this to handle multiple matches: this code only handles a single match, which is sufficient in many cases. Hope this helps ...
I am Arthur, King of the Britons. And this is a tiny ad:
SKIP - a book about connecting industrious people with elderly land owners