當前位置: 首頁>>代碼示例>>Python>>正文


Python Auth.search_entry_by_attribute方法代碼示例

本文整理匯總了Python中pykolab.auth.Auth.search_entry_by_attribute方法的典型用法代碼示例。如果您正苦於以下問題:Python Auth.search_entry_by_attribute方法的具體用法?Python Auth.search_entry_by_attribute怎麽用?Python Auth.search_entry_by_attribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pykolab.auth.Auth的用法示例。


在下文中一共展示了Auth.search_entry_by_attribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_resource_invitationpolicy

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import search_entry_by_attribute [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

示例2: get_resource_owner

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import search_entry_by_attribute [as 別名]
def get_resource_owner(resource):
    """
        Get this resource's owner record
    """
    global auth

    if not auth:
        auth = Auth()
        auth.connect()

    owners = []

    if resource.has_key('owner'):
        if not isinstance(resource['owner'], list):
            owners = [ resource['owner'] ]
        else:
            owners = resource['owner']

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

        for dn,collection in collections:
            if collection.has_key('owner') and isinstance(collection['owner'], list):
                owners += collection['owner']
            elif collection.has_key('owner'):
                owners.append(collection['owner'])

    for dn in owners:
        owner = auth.get_entry_attributes(None, dn, ['cn','mail','telephoneNumber'])
        if owner is not None:
            return owner

    return None
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:38,代碼來源:module_resources.py


注:本文中的pykolab.auth.Auth.search_entry_by_attribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。