def delete_test_accounts(): kadmin_local = subprocess.Popen(['kadmin.local'], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) command = u'' for account in TEST_ACCOUNTS: command += u'delprinc -force {0}\n'.format(account) kadmin_local.communicate(command.encode()) kadmin_local.wait()
def database_size(): kadmin_local = subprocess.Popen(['kadmin.local'], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdoutdata, stderrdata) = kadmin_local.communicate(u'listprincs\n'.encode()) kadmin_local.wait() # We subtract two because the pipe contains the following in addition to the principals # # kadmin.local: listprincs # kadmin.local: # return stdoutdata.decode().count('\n') - 2