(principal, keytabFile)
Add keytab entries for the specified principal to keytab file.
Add keytab entries for the specified principal to keytab file.
Add keytab entries for the specified principal to keytab file .
def dsAddPrincipalEntries(principal, keytabFile):
    '''
    Add keytab entries for the specified principal to keytab file.
    '''
    upn = principal.PrincipalName
    if upn == "":
        realm = defaultRealm
    else:
        name1, realm = upn.split('@')
        if realm == "":
            realm = defaultRealm
    SAMAccountName = principal.SAMAccountName
    if SAMAccountName == "":
        sys.stderr.write("SAM account name is blank. Skipping principal.\n")
        return
    if realm == "":
        sys.stderr.write("Realm is blank. Skipping principal {0}.\n".format(SAMAccountName))
        return
    sys.stderr.write("Processing principal {0}.\n".format(SAMAccountName))
    timestamp = dsGetPOSIXTimeStamp(principal.PasswordLastSet)
    nameType = 1 # KRB5_NT_PRINCIPAL
    kerberosKeys = dsGetPrincipalKerberosKeys(principal)
    if kerberosKeys != None:
        sys.stderr.write("Using supplemental credentials.\n")
        dsPrincipalKeytabFromSupplementalCredentials(kerberosKeys, realm, SAMAccountName, nameType, timestamp)
        return
    (lmhistory, nthistory) = principal.getPasswordHistory()
    if nthistory != None and len(nthistory) > 0:
        sys.stderr.write("Using NT history.\n")
        dsPrincipalKeytabFromNTHistory(nthistory, realm, SAMAccountName, nameType, timestamp)
        return
    (lm, nt) = principal.getPasswordHashes()
    if nt != "":
        sys.stderr.write("Using NT hash.\n")
        dsPrincipalKeytabFromNTHash(nt, realm, SAMAccountName, nameType, timestamp)
        return
    sys.stderr.write("No information about kerberos keys.\n")
def dsAddPrincipalEntries ( principal , keytabFile ) : upn = principal . PrincipalName if upn == "" : realm = defaultRealm else : name1 , realm = upn . split ( '@' ) if realm == "" : realm = defaultRealm SAMAccountName = principal . SAMAccountName if SAMAccountName == "" : sys . stderr . write ( "SAM account name is blank. Skipping principal.\n" ) return if realm == "" : sys . stderr . write ( "Realm is blank. Skipping principal {0}.\n" . format ( SAMAccountName ) ) return sys . stderr . write ( "Processing principal {0}.\n" . format ( SAMAccountName ) ) timestamp = dsGetPOSIXTimeStamp ( principal . PasswordLastSet ) nameType = 1 # KRB5_NT_PRINCIPAL kerberosKeys = dsGetPrincipalKerberosKeys ( principal ) if kerberosKeys != None : sys . stderr . write ( "Using supplemental credentials.\n" ) dsPrincipalKeytabFromSupplementalCredentials ( kerberosKeys , realm , SAMAccountName , nameType , timestamp ) return ( lmhistory , nthistory ) = principal . getPasswordHistory ( ) if nthistory != None and len ( nthistory ) > 0 : sys . stderr . write ( "Using NT history.\n" ) dsPrincipalKeytabFromNTHistory ( nthistory , realm , SAMAccountName , nameType , timestamp ) return ( lm , nt ) = principal . getPasswordHashes ( ) if nt != "" : sys . stderr . write ( "Using NT hash.\n" ) dsPrincipalKeytabFromNTHash ( nt , realm , SAMAccountName , nameType , timestamp ) return sys . stderr . write ( "No information about kerberos keys.\n" )