예제 #1
0
 @Override
 public void createImapUser(LdapUser user, String parentDn) {
   String cn = buildCn(user.getFirstName(), user.getLastName());
   int uid = getMaxUid() + 1;
   BasicAttributes attrs = getBasicAttributesForUser(user, cn);
   attrs.get("objectclass").add("posixAccount");
   attrs.put("gidnumber", props.getLdapGidNumber());
   attrs.put(props.getLdapUidAttribute(), uid + "");
   attrs.put("homedirectory", props.getHomeDirBase() + "/" + cn);
   attrs.put("uid", cn);
   attrs.put("forward", cn + "@localhost");
   try {
     DirContext ctxt = connect();
     ctxt.bind("cn=" + cn + "," + parentDn, null, attrs);
   } catch (NamingException e) {
     log.error("Error creating user", e);
     throw new RuntimeException(e);
   }
 }