def __new__(cls, group, **kwargs): log.debug("FreeNAS_Group.__new__: enter") log.debug("FreeNAS_Group.__new__: group = %s", group) dflags = _get_dflags() if kwargs.has_key('dflags'): dflags = kwargs['dflags'] obj = None if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_Group(group, **kwargs) elif dflags & U_NT4_ENABLED: obj = FreeNAS_NT4_Group(group, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_Group(group, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_Group(group, **kwargs) if obj is None: obj = FreeNAS_Local_Group(group, **kwargs) if not obj or not obj._gr: obj = None if obj: obj = obj._gr log.debug("FreeNAS_Group.__new__: leave") return obj
def __new__(cls, group, **kwargs): log.debug("FreeNAS_Group.__new__: enter") log.debug("FreeNAS_Group.__new__: group = %s", group) if 'dflags' in kwargs: dflags = kwargs['dflags'] else: dflags = _get_dflags() obj = None if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_Group(group, **kwargs) elif dflags & U_NT4_ENABLED: obj = FreeNAS_NT4_Group(group, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_Group(group, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_Group(group, **kwargs) elif dflags & U_DC_ENABLED: obj = FreeNAS_DomainController_Group(group, **kwargs) if obj is None: obj = FreeNAS_Local_Group(group, **kwargs) if not obj or not obj._gr: obj = None if obj: obj = obj._gr log.debug("FreeNAS_Group.__new__: leave") return obj
def __new__(cls, group, **kwargs): if 'dflags' in kwargs: dflags = kwargs['dflags'] else: dflags = _get_dflags() obj = None try: if dflags & U_AD_ENABLED: obj = FreeNAS_ActiveDirectory_Group(group, **kwargs) elif dflags & U_NIS_ENABLED: obj = FreeNAS_NIS_Group(group, **kwargs) elif dflags & U_LDAP_ENABLED: obj = FreeNAS_LDAP_Group(group, **kwargs) elif dflags & U_DC_ENABLED: obj = FreeNAS_DomainController_Group(group, **kwargs) except: log.debug( 'Failed to get group from directory service, falling back to local', exc_info=True) if obj is None: obj = FreeNAS_Local_Group(group, **kwargs) if not obj or not obj._gr: obj = None if obj: obj = obj._gr return obj