@Override
  public boolean principalExists(String principal, boolean service) throws KerberosOperationException {
    if (!isOpen()) {
      throw new KerberosOperationException("This operation handler has not been opened");
    }
    if (principal == null) {
      throw new KerberosOperationException("principal is null");
    }

    DeconstructedPrincipal deconstructPrincipal = createDeconstructPrincipal(principal);

    try {
      return (findPrincipalDN(deconstructPrincipal.getNormalizedPrincipal()) != null);
    } catch (NamingException ne) {
      throw new KerberosOperationException("can not check if principal exists: " + principal, ne);
    }
  }
Test to see if the specified principal exists in a previously configured KDC
<p/>
The implementation is specific to a particular type of KDC.

@param principal a String containing the principal to test
@param service   a boolean value indicating whether the principal is for a service or not
@return true if the principal exists; false otherwise
@throws KerberosOperationException
ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java