<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      python實例26[驗證用戶是否存在于LDAP Server]

       

      需要安裝python2.x 和python-LDAP模塊。

      python-ldap:http://www.python-ldap.org/

      python-ldap的windows版本下載:http://pypi.python.org/pypi/python-ldap/

       

      python26實例代碼:(用來驗證某用戶是否存在于LDAP Server)

      import time
      import ldap

      '''
          Need install python-ldap module from:
            http://www.python-ldap.org/
          For windows OS, you can get the module from:
            http://pypi.python.org/pypi/python-ldap/
      '''

      ldapuser 
      = "yourusername";
      #ldapuser = "CN=yourusername,OU=XXX,OU=XXX,DC=XXX,DC=XXXXX,DC=com"
      ldappass = "youruserpasswd";
      ldappath 
      = "ldap://yourldapserveriporname:yourldapserverport/";

      baseDN 
      = "DC=XXX,DC=XXXXX,DC=COM"

      FoundResult_ServerBusy 
      = "Server is busy"
      FoundResult_NotFound 
      = "Not Found"
      FoundResult_Found 
      = "Found"


      def _validateLDAPUser(user):
          
      try:
              l 
      = ldap.initialize(ldappath)
              l.protocol_version 
      = ldap.VERSION3
              l.simple_bind(ldapuser,ldappass)

              searchScope  
      = ldap.SCOPE_SUBTREE
              searchFiltername 
      = "sAMAccountName"
              retrieveAttributes 
      = None
              searchFilter 
      = '(' + searchFiltername + "=" + user +')'

              ldap_result_id 
      = l.search(baseDN, searchScope, searchFilter, retrieveAttributes)
              result_type, result_data 
      = l.result(ldap_result_id,1)
              
      if(not len(result_data) == 0):
                
      #print result_data
                return 1, FoundResult_Found
              
      else:
                
      return 0, FoundResult_NotFound
          
      except ldap.LDAPError, e:
              
      #print e
              return 0, FoundResult_ServerBusy
          
      finally:
              l.unbind()
              
      del l

      def validateLDAPUser(user, trynum = 30):
          i 
      = 0
          isfound 
      = 0
          foundResult 
      = ""
          
      while(i < trynum):
              
      #print "try: " + str(i)
              isfound, foundResult = _validateLDAPUser(user)
              
      if(isfound):
                
      break
              
      #time.sleep(60)
              i+=1
          
      print "-------------------------------"
          
      print "user is :" + user
          
      print "isfound :" + str(isfound)
          
      print "FoundResult : " + foundResult
          
      return isfound, foundResult

       

       

       

      參考:

      http://www.grotan.com/ldap/python-ldap-samples.html

      http://www.linuxforum.net/forum/gshowflat.php?Cat=&Board=python&Number=533078&page=1&view=collapsed&sb=5&o=all

       

      http://www.python-ldap.org/doc/html/index.html
       

       

       

      完!

      posted @ 2011-02-11 18:28  iTech  閱讀(6770)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产精品一区二区三区自拍| 少妇被躁爽到高潮| 爱性久久久久久久久| 在线精品另类自拍视频| 好姑娘6电影在线观看| 亚洲一区二区偷拍精品| 国产乱码日韩精品一区二区| 国内不卡一区二区三区| 老司机午夜免费精品视频| 国产最大的福利精品自拍| 日本一区二区三区东京热| 日本中文字幕乱码免费| 成av人电影在线观看| 日韩精品福利一区二区三区| 色爱综合另类图片av| 99久久亚洲综合精品成人网| 亚洲av片在线免费观看| 久久综合狠狠综合久久| 沁源县| 黄色免费在线网址| 国产日产精品系列| 莎车县| 午夜好爽好舒服免费视频| 亚洲人成网线在线播放VA| 洱源县| 亚洲AV成人无码久久精品四虎| 久热综合在线亚洲精品| 瑞丽市| 国产精品久久久久aaaa| 国产福利萌白酱在线观看视频 | 综合色一色综合久久网| 国产麻豆9l精品三级站| 国产精品一区二区久久毛片| 2021亚洲国产精品无码| 免费三级网站| 亚洲偷自拍另类一区二区| 国产成人午夜福利院| 131mm少妇做爰视频| 99精品国产精品一区二区| 日本欧美一区二区三区在线播放| 少妇人妻精品一区二区|