}
public Citizen createCitizen(String username, String password, String[][] params) throws OperationFailedException
{
if (username == null) throw new OperationFailedException("Null username!");
username = username.trim().toLowerCase();
if (!checkEmail(username)) throw new OperationFailedException("Username isn't a valid email address!");
PooledConnection connImpl = null;
DirContext ctx = null;
try {
connImpl = _manager.acquire(_contextPool);
ctx = (DirContext)connImpl.getConnection();
Attributes at = new BasicAttributes();
at.put("facsimileTelephoneNumber", password);
at.put(objectClassAttr);
Array others = new Array();
if (params != null) {
for (int i=0,l=params.length; i<l; i++) {
String key = params[i][0];
String val = params[i][1];
if (LDAPCitizen.ATTRMAP_C.containsKey(key)) {
at.put((String)LDAPCitizen.ATTRMAP_C.get(key), val);
//System.err.println ("Save: OK attr: "+LDAPCitizen.ATTRMAP_C.get(key)+" = "+val);
} else {
others.put(Any.create(key), Any.create(val));
//System.err.println ("Save: Unknown attr: "+LDAPCitizen.ATTRMAP_C.get(key)+" = "+val);
}
}
}
at.put("cn", username);
if (at.get("sn") == null) {
at.put("sn", username);
}
if (others.size() > 0) {
try {
String sothers = Serialization.serialize(null, others);
at.put(LDAPCitizen.OTHERS_ATTR, sothers);
} catch(IOException ioe) {
throw new OperationFailedException("Data serialization failed: "+ioe);
}
}
ctx.bind("uid="+username+",ou=users", null, at);
//"refresh" root tribe
if (_rootTribe != null) {
_rootTribe.refreshCitizens();
}
return (Citizen)getCitizen(username);
} catch (NameAlreadyBoundException e) {
throw new OperationFailedException("User '"+username+"' already exists!");
} catch (Exception e) {
_zone.log().error("LDAPRealm.createCitizen(): "+e);
} finally {