def __get__(self, instance, instance_type=None): model_dn = Dn(instance.dn).child(self.intermediate).dn_path to_model = get_model(self.to_model) models = [] try: models = instance.directory.search(to_model, basedn=model_dn) except ObjectNotFound: pass return MockManager(models)
def get_tenant_stores_exh_(self, tenant): # deprecated: # uses OpenUserStoresTable, no way to get an IMsgStore from there, # cannot open using tags.PR_STORE_ENTRYID '''List all stores for tenant, including orphans.''' service_admin = self.get_service_admin() table = service_admin.OpenUserStoresTable(tags.MAPI_UNICODE) table.SetColumns([ tags.PR_DISPLAY_NAME_W, tags.PR_EC_COMPANYID, tags.PR_EC_COMPANY_NAME_W, tags.PR_EC_STOREGUID, tags.PR_EC_STORETYPE, tags.PR_MESSAGE_SIZE_EXTENDED, tags.PR_STORE_ENTRYID, #tags.PR_EC_USERNAME_W, #tags.PR_ENTRYID, ], 0) cnt = table.GetRowCount(0) rows = table.QueryRows(cnt, 0) stores = [] matched_rows = [] for row in rows: entryId = row[6].Value from debug import pprint_propvaluelist pprint_propvaluelist(row) self.session.OpenMsgStore(0, entryId, tags.IID_IMsgStore, tags.MDB_WRITE) items = row for item in items: key = lookup_propvalue_key(item) if key == tags.PR_EC_COMPANY_NAME_W: if tenant.o == item.Value: matched_rows.append(row) model = get_model('models_ldap.User') for row in matched_rows: user = model.get_by_userid(row[0].Value) dct = dict( lastLogon=None, size=row[5].Value, zarafaId=binguid_to_hexstr(row[3].Value), tenant=tenant, user=user, userId=row[0].Value, ) store = Store(initial=dct) stores.append(store) return stores
def fget(self, instance): dns = instance._get_attr(self.name) if dns: if self.rdn_is_fk: pk = dns[0] else: pk = Dn(dns[0]).rdn_value to_model = get_model(self.to_model) models = instance.directory.search(to_model, search_filter=eq(to_model._rdn_, pk)) return models[0]
def fget(self, instance): models = [] to_model = get_model(self.to_model) try: dns = instance._get_attr(self.name) if dns: if self.parent_dn: f = lambda dn: u'{0}={1}'.format(self.rdn_field, dn) dns = [Dn(self.parent_dn).child(f(dn)).dn_path for dn in dns] models = [instance.directory.search(to_model, basedn=dn)[0] for dn in dns] except ObjectNotFound: pass return MockManager(models)
def get_user_store(self, userid): imsgstore = self._find_user_store(userid) if not imsgstore: try: model = get_model('models_ldap.User') user = model.get_by_userid(userid) session = self.get_session(user.zarafaUserServer) store = GetDefaultStore(session) service_admin = store.QueryInterface(tags.IID_IECServiceAdmin) userEntryId = service_admin.ResolveUserName(userid, tags.MAPI_UNICODE) service_admin.CreateStore(tags.ECSTORE_TYPE_PRIVATE, userEntryId) except Exception as e: logger.exception(e) imsgstore = self._find_user_store(userid) return self._get_store_model(imsgstore)
def __get__(self, instance, instance_type=None): pk = Dn(instance.dn).parent.parent.rdn_value # handle up/down tree to_model = get_model(self.to_model) models = instance.directory.search(to_model, search_filter=eq(to_model._rdn_, pk)) return models[0]