}
String[] attrs = split(hr.get("attributes"));
if (dn != null) {
LDAPEntry entry = ld.read(dn, attrs);
/*
* match was found.
*/
if ((entry != null) && (entry.getDN() != null)) {
shove(hr.request.props, name, entry, attrs);
}
return;
}
String search = hr.get("search");
/*
* LDAPSearchConstraints sc = ld.getSearchConstraints();
* sc.setMaxResults( 0 );
* try {
* ld.setOption(LDAPv2.SIZELIMIT,
* Integer.decode(hr.get("limit","1000")));
* } catch (Exception e) {}
*/
StringBuffer sb = new StringBuffer();
LDAPSearchResults results = ld.search(base, scope, search,
attrs, false);
for (int i = 0; results.hasMoreElements(); i++) {
sb.append(i).append(' ');
shove(hr.request.props, name + i + ".", results.next(),
attrs);
}
hr.request.props.put(name + "rows", sb.toString().trim());
} else if (hr.get("modattr") != null) {
// Support delete, modify and add an attribute in one operation
// .. nodattrs="cn|uid=x" actions="d r a"
String actions[] = split( hr.get("actions") );
if ( actions == null ){
return;
}
LDAPModificationSet attrs = new LDAPModificationSet();
addattrs(hr.get("modattr"), attrs, actions);
System.out.println ( attrs );
ld.modify( dn, attrs );
} else if (hr.get("delete") != null) {
ld.delete(dn);
} else if (hr.get("add") != null) {
String add = hr.get("add");
System.out.println(add);
LDAPAttributeSet attrs = new LDAPAttributeSet();
LDAPAttribute attr = new LDAPAttribute("objectclass");
for (int i = 0; i < objectclass_values.length; i++) {
attr.addValue(objectclass_values[i]);
}
attrs.add(attr);
// The add string will look like this: cn=x,y|sn=u,z|x3=p...
addattrs(add, attrs, null);
// attrs.add(new LDAPAttribute("uid", "x1"));
LDAPEntry myEntry = new LDAPEntry(dn, attrs);
System.out.println(myEntry);
ld.add(myEntry);
}