<legend id='bZHoK'><style id='bZHoK'><dir id='bZHoK'><q id='bZHoK'></q></dir></style></legend>

<small id='bZHoK'></small><noframes id='bZHoK'>

    • <bdo id='bZHoK'></bdo><ul id='bZHoK'></ul>
  • <tfoot id='bZHoK'></tfoot>
      1. <i id='bZHoK'><tr id='bZHoK'><dt id='bZHoK'><q id='bZHoK'><span id='bZHoK'><b id='bZHoK'><form id='bZHoK'><ins id='bZHoK'></ins><ul id='bZHoK'></ul><sub id='bZHoK'></sub></form><legend id='bZHoK'></legend><bdo id='bZHoK'><pre id='bZHoK'><center id='bZHoK'></center></pre></bdo></b><th id='bZHoK'></th></span></q></dt></tr></i><div id='bZHoK'><tfoot id='bZHoK'></tfoot><dl id='bZHoK'><fieldset id='bZHoK'></fieldset></dl></div>

        Python-ldap:是否可以在不显式写入密码的情况下进行绑定?

        Python-ldap: is it possible to bind without explicitly writing the password?(Python-ldap:是否可以在不显式写入密码的情况下进行绑定?)

          1. <tfoot id='B2G5H'></tfoot>

            <small id='B2G5H'></small><noframes id='B2G5H'>

            <i id='B2G5H'><tr id='B2G5H'><dt id='B2G5H'><q id='B2G5H'><span id='B2G5H'><b id='B2G5H'><form id='B2G5H'><ins id='B2G5H'></ins><ul id='B2G5H'></ul><sub id='B2G5H'></sub></form><legend id='B2G5H'></legend><bdo id='B2G5H'><pre id='B2G5H'><center id='B2G5H'></center></pre></bdo></b><th id='B2G5H'></th></span></q></dt></tr></i><div id='B2G5H'><tfoot id='B2G5H'></tfoot><dl id='B2G5H'><fieldset id='B2G5H'></fieldset></dl></div>
          2. <legend id='B2G5H'><style id='B2G5H'><dir id='B2G5H'><q id='B2G5H'></q></dir></style></legend>

              <tbody id='B2G5H'></tbody>

                  <bdo id='B2G5H'></bdo><ul id='B2G5H'></ul>
                • 本文介绍了Python-ldap:是否可以在不显式写入密码的情况下进行绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  编写一个 Python 脚本,我想知道是否可以在不以明文形式写入密码的情况下绑定到 LDAP 服务器,如下例所示:

                  Writing a Python script, I would like to know if it is possible to bind to an LDAP server without writing the password in plaintext, like in this example:

                  import ldap
                  
                  l = ldap.open("myserver")
                  username = "cn=Manager, o=mydomain.com"
                  
                  ## I don't want to write the password here in plaintext
                  password  = "secret"
                  
                  l.simple_bind(username, password)
                  

                  推荐答案

                  解密名为.credentials"的文件的示例函数.这当然会有一个单独的脚本,在尝试使用它之前首先将凭据加密到文件中.

                  Example Function for decrypting a file called '.credentials'. This would of course have a seporate script to encrypt the credentials to a file in the first place prior to trying to use it.

                  所以你会调用这个函数:

                  So you would call this function:

                  username, password = decrypt()
                  
                  l.simple_bind(username, password)
                  
                  from Crypto.Cipher import AES
                  import base64
                  from local_logging import info
                  
                  def decrypt(dir_path):
                      #Read '.credentials' file and return unencrypted credentials (user_decoded, pass_decoded)
                  
                      lines = [line.rstrip('
                  ') for line in open(dir_path + '/.credentials')]
                  
                      user_encoded = lines[0]
                      user_secret = lines[1]
                      pass_encoded = lines[2]
                      pass_secret = lines[3]
                  
                      # the character used for padding--with a block cipher such as AES, the value
                      # you encrypt must be a multiple of BLOCK_SIZE in length.  This character is
                      # used to ensure that your value is always a multiple of BLOCK_SIZE
                      PADDING = '{'
                  
                      DecodeAES = lambda c, e: c.decrypt(base64.b64decode(e)).rstrip(PADDING)
                  
                      # create a cipher object using the random secret
                      user_cipher = AES.new(user_secret)
                      pass_cipher = AES.new(pass_secret)
                  
                      # decode the encoded string
                      user_decoded = DecodeAES(user_cipher, user_encoded)
                      pass_decoded = DecodeAES(pass_cipher, pass_encoded)
                  
                      return (user_decoded, pass_decoded)
                  

                  这篇关于Python-ldap:是否可以在不显式写入密码的情况下进行绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                • <i id='U5YNh'><tr id='U5YNh'><dt id='U5YNh'><q id='U5YNh'><span id='U5YNh'><b id='U5YNh'><form id='U5YNh'><ins id='U5YNh'></ins><ul id='U5YNh'></ul><sub id='U5YNh'></sub></form><legend id='U5YNh'></legend><bdo id='U5YNh'><pre id='U5YNh'><center id='U5YNh'></center></pre></bdo></b><th id='U5YNh'></th></span></q></dt></tr></i><div id='U5YNh'><tfoot id='U5YNh'></tfoot><dl id='U5YNh'><fieldset id='U5YNh'></fieldset></dl></div>
                  <legend id='U5YNh'><style id='U5YNh'><dir id='U5YNh'><q id='U5YNh'></q></dir></style></legend>

                      1. <tfoot id='U5YNh'></tfoot>

                            <bdo id='U5YNh'></bdo><ul id='U5YNh'></ul>

                            <small id='U5YNh'></small><noframes id='U5YNh'>

                              <tbody id='U5YNh'></tbody>