コード例 #1
0
ファイル: ServerTreeItem.py プロジェクト: einaru/luma
    def fetchChildList(self):
        """
        Gets the list of baseDNs for the server and return them.
        """
                
        connection = LumaConnectionWrapper(self.serverMeta)
        
        # If baseDNs are aleady spesified
        if self.serverMeta.autoBase == False:
            self.logger.debug("autoBase=False")
            tmpList = self.serverMeta.baseDN
            
            #Need to bind in order to fetch the data for the baseDNs
            bindSuccess, exceptionObject = connection.bindSync()
            if not bindSuccess:
                self.logger.debug("Bind failed.")
                tmp = LDAPErrorItem(str("["+exceptionObject[0]["desc"]+"]"), self, self)
                # We're adding the error as LDAPErrorItem-child, so return True
                return (True, [tmp], exceptionObject)
            
        # Else get them from the server
        else:
            self.logger.debug("Using getBaseDNList()")
            #self.isWorking.emit()
            success, tmpList, exceptionObject = connection.getBaseDNListSync()
        
            if not success:
                self.logger.debug("getBaseDNList failed:"+str(exceptionObject))
                tmp = LDAPErrorItem(str("["+exceptionObject[0]["desc"]+"]"), self, self)
                return (True, [tmp], exceptionObject) #See above
            
            #getBaseDNList calles unbind(), so let's rebind
            connection.bindSync()
        
        self.logger.debug("Entering for-loop")

        # Get the info for the baseDNs
        newChildList = []
        for base in tmpList:
            success, resultList, exceptionObject = connection.searchSync(base, \
                    scope=ldap.SCOPE_BASE,filter='(objectclass=*)', sizelimit=1)
            if not success:
                self.logger.debug("Couldn't search item:"+str(exceptionObject))
                tmp = LDAPErrorItem(str(base+" ["+exceptionObject[0]["desc"]+"]"), self, self)
                newChildList.append(tmp)
                continue
            
            if resultList:
                self.logger.debug("Found item")
                tmp = LDAPTreeItem(resultList[0], self, self)    
                newChildList.append(tmp)
            
        self.logger.debug("End populatItem")
        
        return (True, newChildList, exceptionObject)
コード例 #2
0
ファイル: Search.py プロジェクト: einaru/luma
    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)
コード例 #3
0
ファイル: Search.py プロジェクト: khosrow/luma-devel
    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)
コード例 #4
0
ファイル: ServerTreeItem.py プロジェクト: khosrow/luma-devel
    def fetchChildList(self):
        """
        Gets the list of baseDNs for the server and return them.
        """

        connection = LumaConnectionWrapper(self.serverMeta)

        # If baseDNs are aleady spesified
        if self.serverMeta.autoBase == False:
            self.logger.debug("autoBase=False")
            tmpList = self.serverMeta.baseDN

            #Need to bind in order to fetch the data for the baseDNs
            bindSuccess, exceptionObject = connection.bindSync()
            if not bindSuccess:
                self.logger.debug("Bind failed.")
                tmp = LDAPErrorItem(
                    str("[" + exceptionObject[0]["desc"] + "]"), self, self)
                # We're adding the error as LDAPErrorItem-child, so return True
                return (True, [tmp], exceptionObject)

        # Else get them from the server
        else:
            self.logger.debug("Using getBaseDNList()")
            #self.isWorking.emit()
            success, tmpList, exceptionObject = connection.getBaseDNListSync()

            if not success:
                self.logger.debug("getBaseDNList failed:" +
                                  str(exceptionObject))
                tmp = LDAPErrorItem(
                    str("[" + exceptionObject[0]["desc"] + "]"), self, self)
                return (True, [tmp], exceptionObject)  #See above

            #getBaseDNList calles unbind(), so let's rebind
            connection.bindSync()

        self.logger.debug("Entering for-loop")

        # Get the info for the baseDNs
        newChildList = []
        for base in tmpList:
            success, resultList, exceptionObject = connection.searchSync(base, \
                    scope=ldap.SCOPE_BASE,filter='(objectclass=*)', sizelimit=1)
            if not success:
                self.logger.debug("Couldn't search item:" +
                                  str(exceptionObject))
                tmp = LDAPErrorItem(
                    str(base + " [" + exceptionObject[0]["desc"] + "]"), self,
                    self)
                newChildList.append(tmp)
                continue

            if resultList:
                self.logger.debug("Found item")
                tmp = LDAPTreeItem(resultList[0], self, self)
                newChildList.append(tmp)

        self.logger.debug("End populatItem")

        return (True, newChildList, exceptionObject)