/// <summary> /// Gets the store group non members. /// </summary> /// <returns></returns> public IAzManStoreGroupMember[] GetStoreGroupNonMembers() { if (this.groupType != GroupType.Basic) { throw new InvalidOperationException("Method not supported for LDAP Groups"); } var sgnm = (from f in this.db.StoreGroupMembers() where ( this.store.Storage.Mode == NetSqlAzManMode.Administrator && f.WhereDefined != (byte)WhereDefined.Local || this.store.Storage.Mode == NetSqlAzManMode.Developer) && f.StoreGroupId == this.storeGroupId && f.IsMember == false select f).ToList(); int index = 0; IAzManStoreGroupMember[] storeGroupNonMembers = new SqlAzManStoreGroupMember[sgnm.Count]; foreach (var row in sgnm) { storeGroupNonMembers[index] = new SqlAzManStoreGroupMember(this.db, this, row.StoreGroupMemberId.Value, new SqlAzManSID(row.ObjectSid.ToArray(), row.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)row.WhereDefined, row.IsMember.Value, this.ens); if (this.ens != null) { this.ens.AddPublisher(storeGroupNonMembers[index]); } index++; } return(storeGroupNonMembers); }
/// <summary> /// Gets the store group member. /// </summary> /// <param name="sid">The object owner.</param> /// <returns></returns> public IAzManStoreGroupMember GetStoreGroupMember(IAzManSid sid) { if (this.groupType != GroupType.Basic) { throw new InvalidOperationException("Method not supported for LDAP Groups"); } StoreGroupMembersResult sgm; if ((sgm = (from t in this.db.StoreGroupMembers() where t.StoreGroupId == this.storeGroupId && t.ObjectSid == sid.BinaryValue select t).FirstOrDefault()) != null) { if (this.store.Storage.Mode == NetSqlAzManMode.Administrator && sgm.WhereDefined == (byte)WhereDefined.Local) { throw SqlAzManException.StoreGroupMemberNotFoundException(sid.StringValue, this, null); } else { IAzManStoreGroupMember result = new SqlAzManStoreGroupMember(this.db, this, sgm.StoreGroupMemberId.Value, new SqlAzManSID(sgm.ObjectSid.ToArray(), sgm.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)(sgm.WhereDefined), sgm.IsMember.Value, this.ens); if (this.ens != null) { this.ens.AddPublisher(result); } return(result); } } else { throw SqlAzManException.StoreGroupMemberNotFoundException(sid.StringValue, this, null); } }
/// <summary> /// Creates the store group member. /// </summary> /// <param name="sid">The object owner.</param> /// <param name="whereDefined">Where member is defined.</param> /// <param name="isMember">if set to <c>true</c> [is member].</param> /// <returns></returns> public IAzManStoreGroupMember CreateStoreGroupMember(IAzManSid sid, WhereDefined whereDefined, bool isMember) { if (this.groupType != GroupType.Basic) { throw new InvalidOperationException("Method not supported for LDAP Groups"); } if (this.store.Storage.Mode == NetSqlAzManMode.Administrator && whereDefined == WhereDefined.Local) { throw new SqlAzManException("Cannot create Store Group members defined on local in Administrator Mode"); } //Loop detection if (whereDefined == WhereDefined.Store) { IAzManStoreGroup storeGroupToAdd = this.store.GetStoreGroup(sid); if (this.detectLoop(storeGroupToAdd)) { throw new SqlAzManException(String.Format("Cannot add '{0}'. A loop has been detected.", storeGroupToAdd.Name)); } } int retV = this.db.StoreGroupMemberInsert(this.store.StoreId, this.storeGroupId, sid.BinaryValue, (byte)whereDefined, isMember); IAzManStoreGroupMember result = new SqlAzManStoreGroupMember(this.db, this, retV, sid, whereDefined, isMember, this.ens); this.raiseStoreGroupMemberCreated(this, result); if (this.ens != null) { this.ens.AddPublisher(result); } return(result); }
/// <summary> /// Gets the store group non members. /// </summary> /// <returns></returns> public IAzManStoreGroupMember[] GetStoreGroupNonMembers() { if (this.groupType != GroupType.Basic) throw new InvalidOperationException("Method not supported for LDAP Groups"); var sgnm = (from f in this.db.StoreGroupMembers() where ( this.store.Storage.Mode == NetSqlAzManMode.Administrator && f.WhereDefined != (byte)WhereDefined.Local || this.store.Storage.Mode == NetSqlAzManMode.Developer) && f.StoreGroupId == this.storeGroupId && f.IsMember == false select f).ToList(); int index = 0; IAzManStoreGroupMember[] storeGroupNonMembers = new SqlAzManStoreGroupMember[sgnm.Count]; foreach (var row in sgnm) { storeGroupNonMembers[index] = new SqlAzManStoreGroupMember(this.db, this, row.StoreGroupMemberId.Value, new SqlAzManSID(row.ObjectSid.ToArray(), row.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)row.WhereDefined, row.IsMember.Value, this.ens); if (this.ens != null) this.ens.AddPublisher(storeGroupNonMembers[index]); index++; } return storeGroupNonMembers; }
/// <summary> /// Gets the store group member. /// </summary> /// <param name="sid">The object owner.</param> /// <returns></returns> public IAzManStoreGroupMember GetStoreGroupMember(IAzManSid sid) { if (this.groupType != GroupType.Basic) throw new InvalidOperationException("Method not supported for LDAP Groups"); StoreGroupMembersResult sgm; if ((sgm = (from t in this.db.StoreGroupMembers() where t.StoreGroupId == this.storeGroupId && t.ObjectSid == sid.BinaryValue select t).FirstOrDefault()) != null) { if (this.store.Storage.Mode == NetSqlAzManMode.Administrator && sgm.WhereDefined == (byte)WhereDefined.Local) { throw SqlAzManException.StoreGroupMemberNotFoundException(sid.StringValue, this, null); } else { IAzManStoreGroupMember result = new SqlAzManStoreGroupMember(this.db, this, sgm.StoreGroupMemberId.Value, new SqlAzManSID(sgm.ObjectSid.ToArray(), sgm.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)(sgm.WhereDefined), sgm.IsMember.Value, this.ens); if (this.ens != null) this.ens.AddPublisher(result); return result; } } else { throw SqlAzManException.StoreGroupMemberNotFoundException(sid.StringValue, this, null); } }
/// <summary> /// Creates the store group member. /// </summary> /// <param name="sid">The object owner.</param> /// <param name="whereDefined">Where member is defined.</param> /// <param name="isMember">if set to <c>true</c> [is member].</param> /// <returns></returns> public IAzManStoreGroupMember CreateStoreGroupMember(IAzManSid sid, WhereDefined whereDefined, bool isMember) { if (this.groupType != GroupType.Basic) throw new InvalidOperationException("Method not supported for LDAP Groups"); if (this.store.Storage.Mode == NetSqlAzManMode.Administrator && whereDefined == WhereDefined.Local) { throw new SqlAzManException("Cannot create Store Group members defined on local in Administrator Mode"); } //Loop detection if (whereDefined == WhereDefined.Store) { IAzManStoreGroup storeGroupToAdd = this.store.GetStoreGroup(sid); if (this.detectLoop(storeGroupToAdd)) throw new SqlAzManException(String.Format("Cannot add '{0}'. A loop has been detected.", storeGroupToAdd.Name)); } int retV = this.db.StoreGroupMemberInsert(this.store.StoreId, this.storeGroupId, sid.BinaryValue, (byte)whereDefined, isMember); IAzManStoreGroupMember result = new SqlAzManStoreGroupMember(this.db, this, retV, sid, whereDefined, isMember, this.ens); this.raiseStoreGroupMemberCreated(this, result); if (this.ens != null) this.ens.AddPublisher(result); return result; }