X509Certificate cert = certGen.generate( privateKey, "BC" );
// Write the modifications
ModifyRequest request = new ModifyRequestImpl();
request.setName( dn );
request.replace( PRIVATE_KEY_AT, privateKey.getEncoded() );
request.replace( PRIVATE_KEY_FORMAT_AT, privateKey.getFormat() );
request.replace( PUBLIC_KEY_AT, publicKey.getEncoded() );
request.replace( PUBLIC_KEY_FORMAT_AT, publicKey.getFormat() );
request.replace( USER_CERTIFICATE_AT, cert.getEncoded() );
ldapServer.getDirectoryService().getAdminSession().modify( dn, modifications );