1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public boolean putId(String filter)
{
try
{
creationContext();
SearchControls searchCtls = new SearchControls();
searchCtls.setReturningAttributes(returnedAtts);
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = filter;
NamingEnumeration answer = ctx.search(basedn, searchFilter, searchCtls);
while(answer.hasMore())
{
SearchResult sr = (SearchResult)answer.next();
Attributes attrs = sr.getAttributes();
if (attrs != null)
{
attrs.put("employeeID", "10000000000000000");
System.out.println("id"+attrs.get("employeeID"));
return true;
}
}
ctx.close();
}
catch (NamingException e)
{
e.printStackTrace();
}
return false;
} |
Partager