本文整理汇总了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
示例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