2012-05-14 14 views
1

我找到了python-kerberospykadm5python-kerberos可以授權用戶,但沒有添加/編輯/刪除委託人的API。 pykadm5已經很久沒有更新了。我無法使用它連接到KDC。任何人都可以指向我的Python庫添加/編輯/刪除主體?我的操作系統是Ubuntu;我的Python版本是2.6。用於添加/編輯/刪除委託人的Kerberos python lib?

回答

0

你可以參考庫https://github.com/russjancewicz/python-kadmin/,也許這篇文章可以給你一些想法:

def create_test_prinicipal(): 
    data = None 
    if not os.path.isfile(TEST_KEYTAB): 
    command = ''' 
     spawn kadmin.local -p [email protected] 
     expect "kadmin.local:" {{ send "ank {0}\r" }} 
     expect "Enter password for principal" {{ send "{1}\r" }} 
     expect "Re-enter password for principal" {{ send "{1}\r" }} 
     expect "kadmin.local:" {{ send "cpw {0}\r" }} 
     expect "Enter password for principal" {{ send "{1}\r" }} 
     expect "Re-enter password for principal" {{ send "{1}\r" }} 
     expect "kadmin.local:" {{ send "ktadd -kt {2} -norandkey {0}\r"}} 
     expect "kadmin.local:" {{ exit 1 }} 
    '''.format(TEST_PRINCIPAL, TEST_PASSWORD, TEST_KEYTAB) 

    expect = subprocess.Popen(['expect'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 

    expect.communicate(command.encode()) 
    expect.wait() 
+0

僅供參考,@jrennie。 –