当前位置: 首页>>代码示例>>Python>>正文


Python Auth.connect方法代码示例

本文整理汇总了Python中pykolab.auth.Auth.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Auth.connect方法的具体用法?Python Auth.connect怎么用?Python Auth.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykolab.auth.Auth的用法示例。


在下文中一共展示了Auth.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_002_resource_collection

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
 def test_002_resource_collection(self):
     auth = Auth()
     auth.connect()
     attrs = auth.get_entry_attributes(None, self.cars['dn'], ['*'])
     self.assertIn('groupofuniquenames', attrs['objectclass'])
     self.assertEqual(len(attrs['uniquemember']), 3)
     self.assertEqual(attrs['kolabinvitationpolicy'], 'ACT_ACCEPT')
开发者ID:tpokorra,项目名称:pykolab,代码行数:9,代码来源:test_005_resource_add.py

示例2: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    """
        List deleted mailboxes
    """

    try:
        domain = conf.cli_args.pop(0)
    except:
        domain = utils.ask_question(_("Domain"))

    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for primary,secondaries in domains:
        if not domain == primary and not domain in secondaries:
            continue

        folders.extend(imap.lm("user/%%@%s" % (primary)))
        for secondary in secondaries:
            folders.extend(imap.lm("user/%%@%s" % (secondary)))

    print "Deleted folders:"

    for folder in folders:
        if not conf.raw:
            print imap_utf7.decode(folder)
        else:
            print folder
开发者ID:tpokorra,项目名称:pykolab,代码行数:36,代码来源:cmd_list_domain_mailboxes.py

示例3: test_001_two_johns

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_001_two_johns(self):
        from tests.functional.user_add import user_add
        user_add("John", "Doe")
        user_add("John", "Doe")

        time.sleep(3)

        auth = Auth()
        auth.connect()

        max_tries = 20
        while max_tries > 0:
            recipient1 = auth.find_recipient('[email protected]')
            recipient2 = auth.find_recipient('[email protected]')

            if not recipient1 or not recipient2:
                time.sleep(1)
                max_tries -= 1
            else:
                break

        imap = IMAP()
        imap.connect()

        folders = imap.lm('user/[email protected]')
        self.assertEqual(len(folders), 1, "No INBOX found for first John")

        folders = imap.lm('user/[email protected]')
        self.assertEqual(len(folders), 1, "No INBOX found for second John")
开发者ID:tpokorra,项目名称:pykolab,代码行数:31,代码来源:test_003_two_johns.py

示例4: test_002_user_recipient_policy_duplicate

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_002_user_recipient_policy_duplicate(self):
        from tests.functional.user_add import user_add
        user = {
                'local': 'jane.doe',
                'domain': 'example.org'
            }
        user_add("Jane", "Doe")

        time.sleep(3)

        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient("%(local)[email protected]%(domain)s" % (user))
        if hasattr(self, 'assertIsInstance'):
            self.assertIsInstance(recipient, str)

        self.assertEqual(recipient, "uid=doe2,ou=People,dc=example,dc=org")

        result = wap_client.user_info(recipient)

        if not result.has_key('mailhost'):
            from tests.functional.synchronize import synchronize_once
            synchronize_once()

        result = wap_client.user_info(recipient)

        self.assertEqual(result['mail'], '[email protected]')
        self.assertEqual(result['alias'], ['[email protected]', '[email protected]'])
开发者ID:tpokorra,项目名称:pykolab,代码行数:30,代码来源:test_001_user_sync.py

示例5: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    auth = Auth()
    log.debug(_("Listing domains..."), level=5)
    start_time = time.time()
    domains = auth.list_domains()
    end_time = time.time()
    log.debug(
            _("Found %d domains in %d seconds") % (
                    len(domains),
                    (end_time-start_time)
                ),
            level=8
        )

    all_folders = []

    for primary_domain,secondary_domains in domains:
        log.debug(_("Running for domain %s") % (primary_domain), level=8)
        auth.connect(primary_domain)
        start_time = time.time()
        auth.synchronize()
        end_time = time.time()

        log.info(_("Synchronizing users for %s took %d seconds")
                % (primary_domain, (end_time-start_time))
            )
开发者ID:detrout,项目名称:pykolab,代码行数:28,代码来源:cmd_sync.py

示例6: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    """
        List deleted mailboxes
    """
    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for domain in list(set(domains.keys())):
        folders.extend(imap.lm("DELETED/*@%s" % (domain)))

    folders.extend(imap.lm("DELETED/*"))

    print "Deleted folders:"

    for folder in folders:
        mbox_parts = imap.parse_mailfolder(folder)

        if not conf.raw:
            print "%s (Deleted at %s)" % (imap_utf7.decode(folder).encode('utf-8'), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
        else:
            print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
开发者ID:tpokorra,项目名称:pykolab,代码行数:29,代码来源:cmd_list_deleted_mailboxes.py

示例7: get_resource_invitationpolicy

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def get_resource_invitationpolicy(resource):
    """
        Get this resource's kolabinvitationpolicy configuration
    """
    global auth

    if not resource.has_key('kolabinvitationpolicy') or resource['kolabinvitationpolicy'] is None:
        if not auth:
            auth = Auth()
            auth.connect()

        # get kolabinvitationpolicy attribute from collection
        collections = auth.search_entry_by_attribute('uniquemember', resource['dn'])
        if not isinstance(collections, list):
            collections = [ (collections['dn'],collections) ]

        log.debug("Check collections %r for kolabinvitationpolicy attributes" % (collections), level=9)

        for dn,collection in collections:
            # ldap.search_entry_by_attribute() doesn't return the attributes lower-cased
            if collection.has_key('kolabInvitationPolicy'):
                collection['kolabinvitationpolicy'] = collection['kolabInvitationPolicy']

            if collection.has_key('kolabinvitationpolicy'):
                parse_kolabinvitationpolicy(collection)
                resource['kolabinvitationpolicy'] = collection['kolabinvitationpolicy']
                break

    return resource['kolabinvitationpolicy'] if resource.has_key('kolabinvitationpolicy') else None
开发者ID:tpokorra,项目名称:pykolab,代码行数:31,代码来源:module_resources.py

示例8: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    global imap, pool

    auth = Auth()
    log.debug(_("Listing domains..."), level=5)
    start_time = time.time()
    domains = auth.list_domains()
    end_time = time.time()
    log.debug(
            _("Found %d domains in %d seconds") % (
                    len(domains),
                    (end_time-start_time)
                ),
            level=8
        )

    if version.StrictVersion(sys.version[:3]) >= version.StrictVersion("2.7"):
        pool = multiprocessing.Pool(conf.threads, worker_process, (), 1)
    else:
        pool = multiprocessing.Pool(conf.threads, worker_process, ())

    for primary_domain in list(set(domains.values())):
        log.debug(_("Running for domain %s") % (primary_domain), level=8)
        auth = Auth(primary_domain)
        auth.connect(primary_domain)
        start_time = time.time()
        auth.synchronize(mode='_paged_search', callback=queue_add)
        end_time = time.time()

        log.info(_("Synchronizing users for %s took %d seconds")
                % (primary_domain, (end_time-start_time))
            )

    while not pool._taskqueue.empty():
        time.sleep(1)
开发者ID:tpokorra,项目名称:pykolab,代码行数:37,代码来源:cmd_sync.py

示例9: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    """
        Transfer mailbox
    """

    if len(conf.cli_args) > 1:
        mailfolder = conf.cli_args.pop(0)
        target_server = conf.cli_args.pop(0)

    if len(conf.cli_args) > 0:
        target_partition = conf.cli_args.pop(0)

    imap = IMAP()
    imap.connect()

    mbox_parts = imap.parse_mailfolder(mailfolder)

    if mbox_parts['domain'] == None:
        domain = conf.get('kolab', 'primary_domain')
        user_identifier = mbox_parts['path_parts'][1]
    else:
        domain = mbox_parts['domain']
        user_identifier = "%[email protected]%s" % (mbox_parts['path_parts'][1], mbox_parts['domain'])

    auth = Auth(domain=domain)
    auth.connect()

    user = auth.find_recipient(user_identifier)

    source_server = imap.user_mailbox_server(mailfolder)
    imap.connect(server=source_server)
    imap.imap.xfer(mailfolder, target_server)

    if not user == None and not len(user) < 1:
        auth.set_entry_attributes(domain, user, {'mailhost': target_server})
开发者ID:tpokorra,项目名称:pykolab,代码行数:37,代码来源:cmd_transfer_mailbox.py

示例10: test_001_resource_created

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_001_resource_created(self):
        auth = Auth()
        auth.connect()
        resource = auth.find_resource(self.audi['mail'])
        self.assertEqual(resource, self.audi['dn'])

        collection = auth.find_resource(self.cars['mail'])
        self.assertEqual(collection, self.cars['dn'])
开发者ID:tpokorra,项目名称:pykolab,代码行数:10,代码来源:test_008_resource_add.py

示例11: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    """
        Synchronize or display changes
    """

    imap = IMAP()

    if not conf.connect_server == None:
        imap.connect(server=conf.connect_server)
    else:
        imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = imap.lm()

    imap_domains_not_domains = []

    for folder in folders:
        if len(folder.split('@')) > 1 and not folder.startswith('DELETED'):
            _folder_domain = folder.split('@')[-1]
            if not _folder_domain in list(set(domains.keys() + domains.values())):
                imap_domains_not_domains.append(folder.split('@')[-1])

    imap_domains_not_domains = list(set(imap_domains_not_domains))

    log.debug(_("Domains in IMAP not in LDAP: %r") % (imap_domains_not_domains), level=8)

    if len(imap_domains_not_domains) > 0:
        for domain in imap_domains_not_domains:
            folders = []

            folders.extend(imap.lm('shared/%%@%s' % (domain)))
            folders.extend(imap.lm('user/%%@%s' % (domain)))

            for folder in folders:
                if conf.delete:
                    if conf.dry_run:
                        if not folder.split('/')[0] == 'shared':
                            log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % ('/'.join(folder.split('/')[1:])))
                        else:
                            continue
                    else:
                        if not '/'.join(folder.split('/')[0]) == 'shared':
                            log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
                            try:
                                imap.dm(folder)
                            except Exception, errmsg:
                                log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg))
                        else:
                            log.info(_("Not automatically deleting shared folder '%s'") % (folder))
                else:
                    log.warning(_("No recipients for '%s' (use --delete to delete)!") % ('/'.join(folder.split('/')[1:])))
开发者ID:tpokorra,项目名称:pykolab,代码行数:58,代码来源:cmd_sync_mailhost_attrs.py

示例12: execute

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
def execute(*args, **kw):
    try:
        address = conf.cli_args.pop(0)
    except:
        address = utils.ask_question(_("Email Address"))

    script_to_put = conf.cli_args.pop(0)
    
    script_put_name = conf.cli_args.pop(0)

    auth = Auth()
    auth.connect()

    user = auth.find_recipient(address)

    # Get the main, default backend
    backend = conf.get('kolab', 'imap_backend')

    if len(address.split('@')) > 1:
        domain = address.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    if conf.has_section(domain) and conf.has_option(domain, 'imap_backend'):
        backend = conf.get(domain, 'imap_backend')

    if conf.has_section(domain) and conf.has_option(domain, 'imap_uri'):
        uri = conf.get(domain, 'imap_uri')
    else:
        uri = conf.get(backend, 'uri')

    hostname = None
    port = None

    result = urlparse(uri)

    if hasattr(result, 'hostname'):
        hostname = result.hostname
    else:
        scheme = uri.split(':')[0]
        (hostname, port) = uri.split('/')[2].split(':')

    port = 4190

    # Get the credentials
    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    import sievelib.managesieve
 
    sieveclient = sievelib.managesieve.Client(hostname, port, False)
    sieveclient.connect(None, None, True)
    sieveclient._plain_authentication(admin_login, admin_password, address)
    sieveclient.authenticated = True

    sieveclient.putscript(script_put_name, open(script_to_put, "r").read())
开发者ID:tpokorra,项目名称:pykolab,代码行数:58,代码来源:cmd_put.py

示例13: test_002_fr_FR_user_recipient_policy

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_002_fr_FR_user_recipient_policy(self):
        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient("%(local)[email protected]%(domain)s" % (self.user))
        if hasattr(self, 'assertIsInstance'):
            self.assertIsInstance(recipient, str)

        self.assertEqual(recipient, "uid=fuentes,ou=People,dc=example,dc=org")

        result = wap_client.user_info(recipient)

        self.assertEqual(result['mail'], '[email protected]')
        self.assertEqual(sorted(result['alias']), ['[email protected]', '[email protected]'])
开发者ID:tpokorra,项目名称:pykolab,代码行数:15,代码来源:test_004_user_add_es_ES.py

示例14: test_001_user_recipient_policy

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_001_user_recipient_policy(self):
        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient("%(local)[email protected]%(domain)s" % (self.user))
        if hasattr(self, 'assertIsInstance'):
            self.assertIsInstance(recipient, str)

        self.assertEqual(recipient, "uid=doe,ou=People,dc=example,dc=org")

        result = wap_client.user_info(recipient)

        self.assertEqual(result['mail'], '[email protected]')
        self.assertEqual(result['alias'], ['[email protected]', '[email protected]'])
开发者ID:tpokorra,项目名称:pykolab,代码行数:15,代码来源:test_001_user_sync.py

示例15: test_001_user_rename

# 需要导入模块: from pykolab.auth import Auth [as 别名]
# 或者: from pykolab.auth.Auth import connect [as 别名]
    def test_001_user_rename(self):
        """
            Rename user "Doe, John" to "Sixpack, Joe" and verify the recipient
            policy is applied, and the IMAP INBOX folder for the user is
            renamed.
        """
        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient('[email protected]')
        user_info = wap_client.user_info(recipient)

        if not user_info.has_key('mailhost'):
            from tests.functional.synchronize import synchronize_once
            synchronize_once()

        imap = IMAP()
        imap.connect()
        folders = imap.lm('user/[email protected]')
        self.assertEqual(len(folders), 1)

        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient("%(local)[email protected]%(domain)s" % (self.user))

        user_info = wap_client.user_info(recipient)
        user_info['sn'] = 'Sixpack'
        user_info['givenname'] = 'Joe'
        user_info['uid'] = 'sixpack'
        user_edit = wap_client.user_edit(recipient, user_info)

        time.sleep(2)

        print imap.lm()

        user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org')
        if not user_info['mail'] == '[email protected]':
            from tests.functional.synchronize import synchronize_once
            synchronize_once()
            user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org')

        self.assertEqual(user_info['mail'], '[email protected]')

        print imap.lm()

        folders = imap.lm('user/[email protected]')
        self.assertEqual(len(folders), 0, "INBOX for john.doe still exists")

        folders = imap.lm('user/[email protected]')
        self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
开发者ID:tpokorra,项目名称:pykolab,代码行数:51,代码来源:test_002_user_rename.py


注:本文中的pykolab.auth.Auth.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。