本文整理匯總了Python中pykolab.auth.Auth.get_user_attribute方法的典型用法代碼示例。如果您正苦於以下問題:Python Auth.get_user_attribute方法的具體用法?Python Auth.get_user_attribute怎麽用?Python Auth.get_user_attribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykolab.auth.Auth
的用法示例。
在下文中一共展示了Auth.get_user_attribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PolicyRequest
# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import get_user_attribute [as 別名]
class PolicyRequest(object):
email_address_keys = [ 'sender', 'recipient' ]
recipients = []
auth = None
sasl_domain = None
sasl_user = None
sender_domain = None
sender_user = None
sasl_user_uses_alias = False
sasl_user_is_delegate = False
def __init__(self, policy_request={}):
"""
Creates a new policy request object. Pass it a policy_request
dictionary as described in the Postfix documentation on:
http://www.postfix.org/SMTPD_POLICY_README.html
"""
for key in policy_request.keys():
# Normalize email addresses (they may contain recipient delimiters)
if key in self.email_address_keys:
policy_request[key] = normalize_address(policy_request[key])
if not key == 'recipient':
if policy_request[key] == '':
setattr(self, key, None)
else:
setattr(self, key, policy_request[key])
else:
if not policy_request['recipient'].strip() == '':
self.recipients = list(set(self.recipients + [policy_request['recipient']]))
def add_request(self, policy_request={}):
"""
Add subsequent policy requests to the existing policy request.
All data in the request should be the same as the initial policy
request, but for the recipient - with destination limits set over
1, Postfix may attempt to deliver messages to more then one
recipient during a single delivery attempt, and during submission,
the policy will receive one policy request per recipient.
"""
# Check instance. Not sure what to do if the instance is not the same.
if hasattr(self, 'instance'):
if not policy_request['instance'] == self.instance:
# TODO: We need to empty our pockets
pass
log.debug(
_("Adding policy request to instance %s") % (self.instance),
level=8
)
# Normalize email addresses (they may contain recipient delimiters)
if policy_request.has_key('recipient'):
policy_request['recipient'] = normalize_address(
policy_request['recipient']
)
if not policy_request['recipient'].strip() == '':
self.recipients = list(set(self.recipients + [policy_request['recipient']]))
def parse_ldap_dn(self, dn):
"""
See if parameter 'dn' is a basestring LDAP dn, and if so, return
the results we can obtain from said DN. Return a list of relevant
attribute values.
If not a DN, return None.
"""
values = []
try:
import ldap.dn
ldap_dn = ldap.dn.explode_dn(dn)
except ldap.DECODING_ERROR:
# This is not a DN.
return None
if len(ldap_dn) > 0:
search_attrs = conf.get_list(
'kolab_smtp_access_policy',
'address_search_attrs'
)
rule_subject = self.auth.get_user_attributes(
self.sasl_domain,
{ 'dn': dn },
search_attrs + [ 'objectclass' ]
)
for search_attr in search_attrs:
#.........這裏部分代碼省略.........