1

我发现python-kerberospykadm5python-kerberos可以对用户进行身份验证,但没有用于添加/编辑/删除主体的 api。 pykadm5很久没有更新了。我无法使用它连接到 KDC。谁能指出我添加/编辑/删除主体的python库?我的操作系统是 Ubuntu;我的 Python 版本是 2.6。

4

1 回答 1

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 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()
于 2015-03-13T06:40:51.980 回答