class LDAPClientConnectionLostException(ldaperrors.LDAPException):
class LDAPStartTLSBusyError(ldaperrors.LDAPOperationsError):
class LDAPClient(protocol.Protocol):
    def __str__(self):
    def __init__(self, onwire, message=None):
    def __str__(self):
    def __init__(self):
    def dataReceived(self, recd):
    def connectionMade(self):
    def connectionLost(self, reason=protocol.connectionDone):
    def _send(self, op):
    def _cbSend(self, msg, d):
    def send(self, op):
    def send_multiResponse(self, op, handler, *args, **kwargs):
    def send_noResponse(self, op):
    def unsolicitedNotification(self, msg):
    def handle(self, msg):
    def bind(self, dn='', auth=''):
    def _handle_bind_msg(self, msg):
    def unbind(self):
    def _cbStartTLS(self, msg, ctx):
    def startTLS(self, ctx=None):
    def _startTLS(self, ctx): class PasswordSetAggregateError(Exception):
class PasswordSetAborted(Exception):
class DNNotPresentError(Exception):
class ObjectInBadStateError(Exception):
class ObjectDeletedError(ObjectInBadStateError):
class ObjectDirtyError(ObjectInBadStateError):
class NoContainingNamingContext(Exception):
class CannotRemoveRDNError(Exception):
class MatchNotImplemented(NotImplementedError):
class JournaledLDAPAttributeSet(attributeset.LDAPAttributeSet):
class LDAPEntryWithClient(entry.EditableLDAPEntry):
class LDAPEntryWithAutoFill(LDAPEntry):
    def __init__(self, errors):
    def __str__(self):
    def __repr__(self):
    def __str__(self):
    def __init__(self, key, val=None):
    def __str__(self):
    def __init__(self, op):
    def __str__(self):
    def __init__(self, ldapObject, *a, **kw):
    def add(self, value):
    def update(self, sequence):
    def remove(self, value):
    def clear(self):
    def __init__(self, client, dn, attributes={}, complete=0):
    def buildAttributeSet(self, key, values):
    def _canRemove(self, key, value):
    def _canRemoveAll(self, key):
    def _checkState(self):
    def journal(self, journalOperation):
    def __getitem__(self, *a, **kw):
    def get(self, *a, **kw):
    def has_key(self, *a, **kw):
    def __contains__(self, key):
    def keys(self):
    def items(self):
    def __str__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __len__(self):
    def __nonzero__(self):
    def bind(self, password):
    def _handle_bind_msg(self, msg):
    def __setitem__(self, key, value):
    def __delitem__(self, key):
    def undo(self):
    def _commit_success(self, msg):
    def commit(self):
    def _cbMoveDone(self, msg, newDN):
    def move(self, newDN):
    def _cbDeleteDone(self, msg):
    def delete(self):
    def _cbAddDone(self, msg, dn):
    def addChild(self, rdn, attributes):
    def _cbSetPassword_ExtendedOperation(self, msg):
    def setPassword_ExtendedOperation(self, newPasswd):
    def setPassword_Samba(self, newPasswd, style=None):
    def setPasswordMaybe_Samba(self, newPasswd):
    def _cbSetPassword(self, dl, names):
    def _cbSetPassword_one(self, result):
    def _ebSetPassword_one(self, fail):
    def _setPasswordAll(self, results, newPasswd, prefix, names):
            def cb((success, info)):
    def setPassword(self, newPasswd):
        def _passwordChangerPriorityComparison(me, other):
    def _cbNamingContext_Entries(self, results):
    def namingContext(self):
    def _cbFetch(self, results, overWrite):
    def fetch(self, *attributes):
    def _cbSearchEntry(self, callback, objectName, attributes, complete):
    def _cbSearchMsg(self, msg, d, callback, complete, sizeLimitIsNonFatal):
    def search(self,
               filterText=None,
               filterObject=None,
               attributes=(),
               scope=None,
               derefAliases=None,
               sizeLimit=0,
               sizeLimitIsNonFatal=False,
               timeLimit=0,
               typesOnly=0,
               callback=None):
            def rerouteerr(e):
    def lookup(self, dn):
    def __repr__(self):
    def __init__(self, *args, **kwargs):
    def _cb_addAutofiller(self, r, autoFiller):
    def addAutofiller(self, autoFiller):
    def journal(self, journalOperation): def escape(s):
def unescape(s):
def _splitOnNotEscaped(s, separator):
    def __init__(self, rdn):
    def __str__(self):
    def __init__(self, stringValue=None, attributeType=None, value=None):
    def __str__(self):
    def __repr__(self):
    def __hash__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __gt__(self, other):
    def __le__(self, other):
    def __ge__(self, other):
    def __init__(self, magic=None, stringValue=None, attributeTypesAndValues=None):
    def split(self):
    def __str__(self):
    def __repr__(self):
    def __hash__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __gt__(self, other):
    def __le__(self, other):
    def __ge__(self, other):
    def count(self):
    def __init__(self, magic=None, stringValue=None, listOfRDNs=None):
    def split(self):
    def up(self):
    def __str__(self):
    def __repr__(self):
    def __hash__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __cmp__(self, other):
    def getDomainName(self):
    def contains(self, other):
class InvalidRelativeDistinguishedName(Exception):
class LDAPAttributeTypeAndValue:
class RelativeDistinguishedName:
class DistinguishedName: class LDAPConnector(SRVConnector):
class LDAPClientCreator(protocol.ClientCreator):
    def __init__(self, reactor, dn, factory,
                 overrides=None, bindAddress=None):
    def __getstate__(self):
    def _findOverRide(self, dn, overrides):
    def _isQueryNeeded(self):
    def connect(self):
    def pickServer(self):
    def connect(self, dn, overrides=None, bindAddress=None):
    def connectAnonymously(self, dn, overrides=None):
        def _bind(proto): def alloc_ldap_message_id():
def escape(s):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, value=None, controls=None, id=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def __init__(self):
    def __str__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, version=None, dn=None, auth=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def __init__(self):
    def fromBER(cls, tag, content, berdecoder=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, resultCode=None, matchedDN=None, errorMessage=None, referral=None, serverSaslCreds=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, resultCode=None, matchedDN=None, errorMessage=None, referral=None, serverSaslCreds=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def __init__(self, *args, **kwargs):
    def __str__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, attributeDesc=None, assertionValue=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def __init__(self, tag=None):
    def fromBER(klass, tag, content, berdecoder=None):
    def asText(self):
    def asText(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, value, tag=tag):
    def __repr__(self):
    def __str__(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, type=None, substrings=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def asText(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, matchingRule=None, type=None,
                 matchValue=None, dnAttributes=None,
                 tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self,
                 baseObject=None,
                 scope=None,
                 derefAliases=None,
                 sizeLimit=None,
                 timeLimit=None,
                 typesOnly=None,
                 filter=None,
                 attributes=None,
                 tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, objectName, attributes, tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self,
                 controlType, criticality=None, controlValue=None,
                 id=None, tag=None):
    def __str__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, object=None, modification=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, entry=None, attributes=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def __init__(self, value=None, entry=None, tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, entry, newrdn, deleteoldrdn, newSuperior=None,
                 tag=None):
    def __str__(self):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, requestName, requestValue=None,
                 tag=None):
    def __str__(self):
    def __init__(self, requestName=None,
                 userIdentity=None, oldPasswd=None, newPasswd=None,
                 tag=None):
    def __repr__(self):
    def fromBER(klass, tag, content, berdecoder=None):
    def __init__(self, resultCode=None, matchedDN=None, errorMessage=None,
                 referral=None, serverSaslCreds=None,
                 responseName=None, response=None,
                 tag=None):
    def __str__(self):
    def __init__(self, requestName=None, tag=None):
    def __repr__(self):
class LDAPString(BEROctetString):
class LDAPAttributeValue(BEROctetString):
class LDAPMessage(BERSequence):
class LDAPProtocolOp:
class LDAPProtocolRequest(LDAPProtocolOp):
class LDAPProtocolResponse(LDAPProtocolOp):
class LDAPBERDecoderContext_LDAPBindRequest(BERDecoderContext):
class LDAPBindRequest(LDAPProtocolRequest, BERSequence):
class LDAPReferral(BERSequence):
class LDAPSearchResultReference(LDAPProtocolResponse):
class LDAPResult(LDAPProtocolResponse, BERSequence):
class LDAPBindResponse_serverSaslCreds(BERSequence):
class LDAPBERDecoderContext_BindResponse(BERDecoderContext):
class LDAPBindResponse(LDAPResult):
class LDAPUnbindRequest(LDAPProtocolRequest, BERNull):
class LDAPAttributeDescription(BEROctetString):
class LDAPAttributeValueAssertion(BERSequence):
class LDAPFilter(BERStructured):
class LDAPFilterSet(BERSet):
class LDAPFilter_and(LDAPFilterSet):
class LDAPFilter_or(LDAPFilterSet):
class LDAPFilter_not(LDAPFilter):
class LDAPFilter_equalityMatch(LDAPAttributeValueAssertion):
class LDAPFilter_substrings_initial(LDAPString):
class LDAPFilter_substrings_any(LDAPString):
class LDAPFilter_substrings_final(LDAPString):
class LDAPBERDecoderContext_Filter_substrings(BERDecoderContext):
class LDAPFilter_substrings(BERSequence):
class LDAPFilter_greaterOrEqual(LDAPAttributeValueAssertion):
class LDAPFilter_lessOrEqual(LDAPAttributeValueAssertion):
class LDAPFilter_present(LDAPAttributeDescription):
class LDAPFilter_approxMatch(LDAPAttributeValueAssertion):
class LDAPMatchingRuleId(LDAPString):
class LDAPAssertionValue(BEROctetString):
class LDAPMatchingRuleAssertion_matchingRule(LDAPMatchingRuleId):
class LDAPMatchingRuleAssertion_type(LDAPAttributeDescription):
class LDAPMatchingRuleAssertion_matchValue(LDAPAssertionValue):
class LDAPMatchingRuleAssertion_dnAttributes(BERBoolean):
class LDAPBERDecoderContext_MatchingRuleAssertion(BERDecoderContext):
class LDAPMatchingRuleAssertion(BERSequence):
class LDAPFilter_extensibleMatch(LDAPMatchingRuleAssertion):
class LDAPBERDecoderContext_Filter(BERDecoderContext):
class LDAPSearchRequest(LDAPProtocolRequest, BERSequence):
class LDAPSearchResultEntry(LDAPProtocolResponse, BERSequence):
class LDAPSearchResultDone(LDAPResult):
class LDAPControls(BERSequence):
class LDAPControl(BERSequence):
class LDAPBERDecoderContext_LDAPControls(BERDecoderContext):
class LDAPBERDecoderContext_LDAPMessage(BERDecoderContext):
class LDAPBERDecoderContext_TopLevel(BERDecoderContext):
class LDAPModifyRequest(LDAPProtocolRequest, BERSequence):
class LDAPModifyResponse(LDAPResult):
class LDAPAddRequest(LDAPProtocolRequest, BERSequence):
class LDAPAddResponse(LDAPResult):
class LDAPDelRequest(LDAPProtocolRequest, LDAPString):
class LDAPDelResponse(LDAPResult):
class LDAPModifyDNResponse_newSuperior(LDAPString):
class LDAPBERDecoderContext_ModifyDNRequest(BERDecoderContext):
class LDAPModifyDNRequest(LDAPProtocolRequest, BERSequence):
class LDAPModifyDNResponse(LDAPResult):
class LDAPOID(BEROctetString):
class LDAPResponseName(LDAPOID):
class LDAPResponse(BEROctetString):
class LDAPBERDecoderContext_LDAPExtendedRequest(BERDecoderContext):
class LDAPExtendedRequest(LDAPProtocolRequest, BERSequence):
class LDAPPasswordModifyRequest_userIdentity(BEROctetString):
class LDAPPasswordModifyRequest_oldPasswd(BEROctetString):
class LDAPPasswordModifyRequest_newPasswd(BEROctetString):
class LDAPBERDecoderContext_LDAPPasswordModifyRequest(BERDecoderContext):
class LDAPPasswordModifyRequest(LDAPExtendedRequest):
class LDAPBERDecoderContext_LDAPExtendedResponse(BERDecoderContext):
class LDAPExtendedResponse(LDAPResult):
class LDAPStartTLSRequest(LDAPExtendedRequest):
class LDAPBERDecoderContext(BERDecoderContext): class InvalidLDAPFilter(Exception):
    def __init__(self, msg, loc, text):
    def __str__(self):
def parseExtensible(attr, s):
def _p_escaped(s,l,t):
def _p_simple(s,l,t):
def _p_substring(s,l,t):
def _p_extensible_dn(s,l,t):
def _p_matchingrule_or_none(s,l,t):
def _p_extensible_attr(s,l,t):
def _p_extensible_noattr(s,l,t):
def _p_extensible(s,l,t):
def parseFilter(s):
def _p_maybeSubString_simple(s,l,t):
def _p_maybeSubString_present(s,l,t):
def _p_maybeSubString_substring(s,l,t):
def parseMaybeSubstring(attrType, s): class ILDAPEntry(Interface):
class IEditableLDAPEntry(Interface):
class IConnectedLDAPEntry(Interface):
class ILDAPConfig(Interface):
    def __getitem__(self, key):
    def get(self, key, default=None):
    def has_key(self, key):
    def __contains__(self, key):
    def keys(self):
    def items(self):
    def __str__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __len__(self):
    def __nonzero__(self):
    def bind(self, password):
    def __setitem__(self, key, value):
    def __delitem__(self, key):
    def undo(self):
    def commit(self):
    def move(self, newDN):
    def delete(self):
    def setPassword(self, newPasswd):
    def namingContext(self):
    def fetch(self, *attributes):
    def search(self,
               filterText=None,
               filterObject=None,
               attributes=(),
               scope=None,
               derefAliases=None,
               sizeLimit=0,
               timeLimit=0,
               typesOnly=0,
               callback=None):
    def children(self, callback=None):
    def subtree(self, callback=None):
    def lookup(self, dn):
    def match(self, filter):
    def getBaseDN(self):
    def getServiceLocationOverrides(self):
    def copy(self,
             baseDN=None,
             serviceLocationOverrides=None):
    def getIdentityBaseDN(self):
    def getIdentitySearch(self, name): def _getSearchFields():
def getSearchFieldByName(name, vars):
def getSearchFieldNames(): class ICurrentDN(Interface): def uriQuote(uri):
    uri=str(uri)
    for c in '%;/?:@&+$':
        uri=uri.replace(c, '%%%02x'%ord(c))
    return uri def render(): def render(): def keyvalue(context, data):
def keyvalue_item(context, data):
    def __init__(self, original):
    def child(self, context, name):
    def items(self):
    def __init__(self, original):
    def child(self, context, name):
def dnSerializer(original, context):
def entrySerializer(original, context):
def zebra(styles=['zebra-odd', 'zebra-even']):
    def f(self, ctx, data):
class _DictLike(object):
class LDAPEntryContainer(object):
class IZebraStyle(Interface):
from zope.interface import Interface, implements
from webut.skin import iskin
from ldaptor.protocols.ldap import ldapclient, ldapsyntax
from ldaptor.protocols.ldap import distinguishedname, ldapconnector
from ldaptor.protocols import pureldap
from ldaptor import ldapfilter, interfaces
from twisted.internet import reactor
from ldaptor.apps.webui import config, iwebui
from ldaptor.apps.webui.uriquote import uriQuote
from ldaptor.apps.webui.i18n import _
from ldaptor.apps.webui import i18n
from ldaptor import weave
from nevow import rend, inevow, loaders, url, tags
from formless import annotate, webform, iformless, configurable
import os
    implements(inevow.IContainer)

    filter = None

    def __init__(self):
        super(SearchForm, self).__init__(None)
        self.data = {}

    def getBindingNames(self, ctx):
        return ['search']

    def bind_search(self, ctx):
        l = []
        l.append(annotate.Argument('ctx', annotate.Context()))
        for field in config.getSearchFieldNames():
            l.append(annotate.Argument('search_%s' % field,
                                       annotate.String(label=field)))
        l.append(annotate.Argument('searchfilter',
                                   annotate.String(label=_("Advanced search"))))
        l.append(annotate.Argument(
            'scope',
            annotate.Choice(label=_("Search depth"),
                            choices=[ pureldap.LDAP_SCOPE_wholeSubtree,
                                      pureldap.LDAP_SCOPE_singleLevel,
                                      pureldap.LDAP_SCOPE_baseObject,
                                      ],
                            stringify=strScope,
                            default=pureldap.LDAP_SCOPE_wholeSubtree)))

        return annotate.MethodBinding(
            name='search',
            action=_("Search"),
            typeValue=annotate.Method(arguments=l,
                                      label=_('Search')))

    def search(self, ctx, scope, searchfilter, **kw):
        filt=[]
        for k,v in kw.items():
            assert k.startswith('search_')
            if not k.startswith("search_"):
                continue
            k=k[len("search_"):]
            if v is None:
                continue
            v=v.strip()
            if v=='':
                continue

            # TODO escape ) in v
            # TODO handle unknown filter name right (old form open in browser etc)
            filter_ = config.getSearchFieldByName(k, vars={'input': v})
            filt.append(ldapfilter.parseFilter(filter_))
        if searchfilter:
            try:
                filt.append(ldapfilter.parseFilter(searchfilter))
            except ldapfilter.InvalidLDAPFilter, e:
                raise annotate.ValidateError(
                    {'searchfilter': str(e), },
                    partialForm=inevow.IRequest(ctx).args)

        if filt:
            if len(filt)==1:
                query=filt[0]
            else:
                query=pureldap.LDAPFilter_and(filt)
        else:
            query=pureldap.LDAPFilterMatchAll

        self.data.update(kw)

        # annotate.Choice in nevow 0.3 maps choices to a list, and
        # passes indexes to this list to client. annotate.Choice in
        # 0.4pre converts choice to string and back with callbacks,
        # defaulting to str, and leaving the value as string.  We
        # can't use the 0.4pre mechanism as long as we need 0.3
        # compatibility, so work around that by explicitly making sure
        # scope is an integer.
        scope = int(scope)

        self.data['scope'] = scope
        self.data['searchfilter'] = searchfilter
        self.filter = query
        return self

    def child(self, context, name):
        fn = getattr(self, 'child_%s' % name, None)
        if fn is None:
            return None
        else:
            return fn(context)

    def child_filter(self, context):
        return self.filter.asText()

    def child_results(self, context):
        assert self.filter is not None
        cfg = context.locate(interfaces.ILDAPConfig)

        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        curDN = iwebui.ICurrentDN(context)
        d=c.connectAnonymously(curDN,
                               cfg.getServiceLocationOverrides())

        def _search(proto, dn, searchFilter, scope):
            baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=dn)
            d=baseEntry.search(filterObject=searchFilter,
                               scope=scope,
                               sizeLimit=20,
                               sizeLimitIsNonFatal=True)
            def _cb(result, proto):
                proto.unbind()
                return result
            d.addBoth(_cb, proto)
            return d
        d.addCallback(_search, curDN, self.filter, self.data['scope'])
        return d

    def child_base(self, context):
        cfg = context.locate(interfaces.ILDAPConfig)


        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)