Beispiel #1
0
    def onServerChanged(self, index):
        """Slot for the server combo box.

        When the selected index changes, we want to fetch the baseDN
        list off of the selected server, and populate the baseDN combo
        box.

        :param index: the index of the server entry in the combobox.
        :type index: int
        """
        server = self.searchForm.server.decode('utf-8')

        # No need to try to fetch the base dn list off of no server.
        if server == '':
            self.searchForm.baseDNBox.clear()
            return

        # Get the server object for the selected server.
        # And return if this object is None
        self.currentServer =  self.serverListObject.getServerObject(server)

        if self.currentServer is None:
            return

        #self.connection = LumaConnection(self.currentServer)
        con = LumaConnectionWrapper(self.currentServer, self)

        if self.currentServer.autoBase:
            #success, baseDNList, e = self.connection.getBaseDNList()
            success, baseDNList, e = con.getBaseDNListSync()
            if not success:
                # TODO: give some visual feedback to the user, regarding
                #       the unsuccessful bind operation
                msg = 'Could not retrieve baseDN. Reason:\n{0}'.format(str(e))
                self.searchForm.onSearchError(True, msg)
                self.__logger.error(msg)
        else:
            baseDNList = [self.currentServer.baseDN]

        # Try to populate it with the newly fetched baseDN list.
        # We need make sure the baseDN combo box is cleared before we
        self.searchForm.populateBaseDNBox(baseDNList)

        # Try to fetch the list of available attributes, for use in the
        # filter wizard and for autocompletion.
        # Jippi ay o' what a beautiful var name!!
        ocai = ObjectClassAttributeInfo(self.currentServer)
        attributes = ocai.getAttributeList()
        objectClasses = ocai.getObjectClasses()

        self.filterBuilder.onServerChanged(objectClasses, attributes)

        if self.autocompleteIsEnabled:
            self.searchForm.initAutoComplete(attributes)
Beispiel #2
0
    def onServerChanged(self, index):
        """Slot for the server combo box.

        When the selected index changes, we want to fetch the baseDN
        list off of the selected server, and populate the baseDN combo
        box.

        :param index: the index of the server entry in the combobox.
        :type index: int
        """
        server = self.searchForm.server.decode('utf-8')

        # No need to try to fetch the base dn list off of no server.
        if server == '':
            self.searchForm.baseDNBox.clear()
            return

        # Get the server object for the selected server.
        # And return if this object is None
        self.currentServer = self.serverListObject.getServerObject(server)

        if self.currentServer is None:
            return

        #self.connection = LumaConnection(self.currentServer)
        con = LumaConnectionWrapper(self.currentServer, self)

        if self.currentServer.autoBase:
            #success, baseDNList, e = self.connection.getBaseDNList()
            success, baseDNList, e = con.getBaseDNListSync()
            if not success:
                # TODO: give some visual feedback to the user, regarding
                #       the unsuccessful bind operation
                msg = 'Could not retrieve baseDN. Reason:\n{0}'.format(str(e))
                self.searchForm.onSearchError(True, msg)
                self.__logger.error(msg)
        else:
            baseDNList = [self.currentServer.baseDN]

        # Try to populate it with the newly fetched baseDN list.
        # We need make sure the baseDN combo box is cleared before we
        self.searchForm.populateBaseDNBox(baseDNList)

        # Try to fetch the list of available attributes, for use in the
        # filter wizard and for autocompletion.
        # Jippi ay o' what a beautiful var name!!
        ocai = ObjectClassAttributeInfo(self.currentServer)
        attributes = ocai.getAttributeList()
        objectClasses = ocai.getObjectClasses()

        self.filterBuilder.onServerChanged(objectClasses, attributes)

        if self.autocompleteIsEnabled:
            self.searchForm.initAutoComplete(attributes)