Split a Kerberos principal name into parts

    Returns:
       * ('host', hostname, realm) for a host principal
       * (servicename, hostname, realm) for a service principal
       * (None, username, realm) for a user principal

    :param text name: Kerberos principal name
    :return: (service, host, realm) or (None, username, realm)

def krb5_unparse_principal_name(name):
    """Split a Kerberos principal name into parts

    Returns:
       * ('host', hostname, realm) for a host principal
       * (servicename, hostname, realm) for a service principal
       * (None, username, realm) for a user principal

    :param text name: Kerberos principal name
    :return: (service, host, realm) or (None, username, realm)
    """
    prefix, realm = name.split(u'@')
    if u'/' in prefix:
        service, host = prefix.rsplit(u'/', 1)
        return service, host, realm
    else:
        return None, prefix, realm