g}" ` d dl mZ d dlmZ d dlmZ G d de Z G d d ZdS ) )cpapi)FormattedException)NotSupportedc e Zd ZdS )DomainExceptionN)__name__ __module____qualname__ py/cllimits/domain_lib.pyr r s Dr r c e Zd Zd Zd Zd ZdS )Domainc d | _ d S )N)_userdomain_cache)selfs r __init__zDomain.__init__ s !%r c | j @ t t j d | _ n# t $ r i | _ Y nw xY w| j |d S )z~ Retrive main domain for supplied user :param username: User name :return: Domain name or N/A N)cplogindns)keylszN/A)r dictr cpinfor get)r usernames r get_user_domainzDomain.get_user_domain su !) ,)-elAS.T.T.T)U)U&& , , ,)+&&& ,%))(E:::s '1 AAc t j | }|r|S n@# t t j j f$ r"}t t | |d}~ww xY wt dd|id )zn Retrive username by domain :param domain_name: Domain name :return: Username NzThere is no domain '%(domain)s'domain)messagecontext)r domain_ownerIOErrorcpapiexceptionsr r str)r domain_namer es r get_user_name_by_domainzDomain.get_user_name_by_domain$ s 1)+66H .;<