Server IP : 127.0.0.2 / Your IP : 18.117.9.230 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python2.7/dist-packages/ldap/controls/ |
Upload File : |
# -*- coding: utf-8 -*- """ ldap.controls.openldap - classes for OpenLDAP-specific controls See http://www.python-ldap.org/ for project details. $Id: openldap.py,v 1.6 2015/10/24 16:21:56 stroeder Exp $ """ import ldap.controls from ldap.controls import ValueLessRequestControl,ResponseControl from pyasn1.type import univ from pyasn1.codec.ber import decoder __all__ = [ 'SearchNoOpControl', 'SearchNoOpMixIn', ] class SearchNoOpControl(ValueLessRequestControl,ResponseControl): """ No-op control attached to search operations implementing sort of a count operation see http://www.openldap.org/its/index.cgi?findid=6598 """ controlType = '1.3.6.1.4.1.4203.666.5.18' def __init__(self,criticality=False): self.criticality = criticality class SearchNoOpControlValue(univ.Sequence): pass def decodeControlValue(self,encodedControlValue): decodedValue,_ = decoder.decode(encodedControlValue,asn1Spec=self.SearchNoOpControlValue()) self.resultCode = int(decodedValue[0]) self.numSearchResults = int(decodedValue[1]) self.numSearchContinuations = int(decodedValue[2]) ldap.controls.KNOWN_RESPONSE_CONTROLS[SearchNoOpControl.controlType] = SearchNoOpControl class SearchNoOpMixIn: """ Mix-in class to be used with class LDAPObject and friends. It adds a convenience method noop_search_st() to LDAPObject for easily using the no-op search control. """ def noop_search_st(self,base,scope=ldap.SCOPE_SUBTREE,filterstr='(objectClass=*)',timeout=-1): try: msg_id = self.search_ext( base, scope, filterstr=filterstr, attrlist=['1.1'], timeout=timeout, serverctrls=[SearchNoOpControl(criticality=True)], ) _,_,_,search_response_ctrls = self.result3(msg_id,all=1,timeout=timeout) except ( ldap.TIMEOUT, ldap.TIMELIMIT_EXCEEDED, ldap.SIZELIMIT_EXCEEDED, ldap.ADMINLIMIT_EXCEEDED ),e: self.abandon(msg_id) raise e else: noop_srch_ctrl = [ c for c in search_response_ctrls if c.controlType==SearchNoOpControl.controlType ] if noop_srch_ctrl: return noop_srch_ctrl[0].numSearchResults,noop_srch_ctrl[0].numSearchContinuations else: return (None,None)