def __new__(cls, user, **kwargs): if 'dflags' in kwargs: dflags = kwargs['dflags'] else: dflags = _get_dflags() data = kwargs.pop('data', None) obj = None try: if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_User(user, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_User(user, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_User(user, **kwargs) elif dflags & U_DC_ENABLED: obj = FreeNAS_DomainController_User(user, **kwargs) except: log.debug( 'Failed to get user from directory service, falling back to local', exc_info=True) if not obj: obj = FreeNAS_Local_User(user, data=data, **kwargs) if not obj or not obj._pw: obj = None if obj: obj = obj._pw return obj
def __new__(cls, user, **kwargs): log.debug("FreeNAS_User.__new__: enter") log.debug("FreeNAS_User.__new__: user = %s", user) if 'dflags' in kwargs: dflags = kwargs['dflags'] else: dflags = _get_dflags() data = kwargs.pop('data', None) obj = None if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_User(user, **kwargs) elif dflags & U_NT4_ENABLED: obj = FreeNAS_NT4_User(user, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_User(user, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_User(user, **kwargs) elif dflags & U_DC_ENABLED: obj = FreeNAS_DomainController_User(user, **kwargs) if not obj: obj = FreeNAS_Local_User(user, data=data, **kwargs) if not obj or not obj._pw: obj = None if obj: obj = obj._pw log.debug("FreeNAS_User.__new__: leave") return obj
def __new__(cls, user, **kwargs): log.debug("FreeNAS_User.__new__: enter") log.debug("FreeNAS_User.__new__: user = %s", user) dflags = _get_dflags() if kwargs.has_key('dflags'): dflags = kwargs['dflags'] obj = None if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_User(user, **kwargs) elif dflags & U_NT4_ENABLED: obj = FreeNAS_NT4_User(user, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_User(user, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_User(user, **kwargs) elif dflags & U_DC_ENABLED: obj = FreeNAS_DomainController_User(user, **kwargs) if not obj: obj = FreeNAS_Local_User(user, **kwargs) if not obj or not obj._pw: obj = None if obj: obj = obj._pw log.debug("FreeNAS_User.__new__: leave") return obj