我发现了python-kerberospykadm5python-kerberos可以对用户进行身份验证,但没有用于添加/编辑/删除主体的api。pykadm5很久没有更新了。我不能用它连接到kdc。有人能给我指一个python库来添加/编辑/删除主体吗?我的操作系统是ubuntu;我的python版本是2.6。

最佳答案

您可以参考存储库https://github.com/russjancewicz/python-kadmin/,也许这篇文章可以让您有所了解:

def create_test_prinicipal():
  data = None
  if not os.path.isfile(TEST_KEYTAB):
    command = '''
      spawn kadmin.local -p root@EXAMPLE.COM
      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()

关于python - Kerberos python lib用于添加/编辑/删除主体?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10581716/

10-13 00:25
查看更多