String domainName = "uid=" + adminInfo.getAdminUID() + "," + "ou=Users," + partitionSuffix;
try {
DN adminDn = new DN(domainName);
ServerEntry adminEntry = directoryService.newEntry(adminDn);
List<String> objectClasses = adminInfo.getObjectClasses();
if (kdcEnabled) {
// Add Kerberose specific object classes
objectClasses = new ArrayList<String>(adminInfo.getObjectClasses());
objectClasses.add("krb5principal");
objectClasses.add("krb5kdcentry");
}
addObjectClasses(adminEntry, objectClasses);
adminEntry.add("uid", adminInfo.getAdminUID());
adminEntry.add("sn", adminInfo.getAdminLastName());
adminEntry.add("givenName", adminInfo.getAdminCommonName());
//setting admin full name as uid since 'cn' is a compulsory attribute when constructing a
// user entry.
adminEntry.add("cn", adminInfo.getAdminUID());
adminEntry.add("mail", adminInfo.getAdminEmail());
if (kdcEnabled) {
String principal = adminInfo.getAdminUID() + "@" + realm;
adminEntry.put(KerberosAttribute.KRB5_PRINCIPAL_NAME_AT, principal);
adminEntry.put(KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT, "0");
}
addAdminPassword(adminEntry, adminInfo.getAdminPassword(),
adminInfo.getPasswordAlgorithm(), kdcEnabled);