Esempio n. 1
0
        /// <summary>
        /// Gets the application group all members.
        /// </summary>
        /// <returns></returns>
        public IAzManApplicationGroupMember[] GetApplicationGroupAllMembers()
        {
            if (this.groupType != GroupType.Basic)
            {
                throw new InvalidOperationException("Method not supported for LDAP Groups");
            }
            var agam = (from f in this.db.ApplicationGroupMembers()
                        where
                        (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && f.WhereDefined != (byte)WhereDefined.Local
                         ||
                         this.application.Store.Storage.Mode != NetSqlAzManMode.Administrator)
                        &&
                        f.ApplicationGroupId == this.applicationGroupId
                        select f).ToList();
            int index = 0;

            IAzManApplicationGroupMember[] applicationGroupAllMembers = new SqlAzManApplicationGroupMember[agam.Count];
            foreach (var row in agam)
            {
                applicationGroupAllMembers[index] = new SqlAzManApplicationGroupMember(this.db, this, row.ApplicationGroupMemberId.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(applicationGroupAllMembers[index]);
                }
                index++;
            }
            return(applicationGroupAllMembers);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the application group member.
        /// </summary>
        /// <param name="sid">The object owner.</param>
        /// <returns></returns>
        public IAzManApplicationGroupMember GetApplicationGroupMember(IAzManSid sid)
        {
            if (this.groupType != GroupType.Basic)
            {
                throw new InvalidOperationException("Method not supported for LDAP Groups");
            }
            ApplicationGroupMembersResult agm;

            if ((agm = (from t in this.db.ApplicationGroupMembers() where t.ApplicationGroupId == this.applicationGroupId && t.ObjectSid == sid.BinaryValue select t).FirstOrDefault()) != null)
            {
                if (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && agm.WhereDefined == (byte)WhereDefined.Local)
                {
                    throw SqlAzManException.ApplicationGroupMemberNotFoundException(sid.StringValue, this, null);
                }
                else
                {
                    IAzManApplicationGroupMember result = new SqlAzManApplicationGroupMember(this.db, this, agm.ApplicationGroupMemberId.Value, new SqlAzManSID(agm.ObjectSid.ToArray(), agm.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)(agm.WhereDefined), agm.IsMember.Value, this.ens);
                    if (this.ens != null)
                    {
                        this.ens.AddPublisher(result);
                    }
                    return(result);
                }
            }
            else
            {
                throw SqlAzManException.ApplicationGroupMemberNotFoundException(sid.StringValue, this, null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the application group member.
        /// </summary>
        /// <param name="sid">The object owner.</param>
        /// <param name="whereDefined">The where defined.</param>
        /// <param name="isMember">if set to <c>true</c> [is member].</param>
        public IAzManApplicationGroupMember CreateApplicationGroupMember(IAzManSid sid, WhereDefined whereDefined, bool isMember)
        {
            if (this.groupType != GroupType.Basic)
            {
                throw new InvalidOperationException("Method not supported for LDAP Groups");
            }

            if (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && whereDefined == WhereDefined.Local)
            {
                throw new SqlAzManException("Cannot create Application Group members defined on local in Administrator Mode");
            }
            //Loop detection
            if (whereDefined == WhereDefined.Application)
            {
                IAzManApplicationGroup applicationGroupToAdd = this.application.GetApplicationGroup(sid);
                if (this.detectLoop(applicationGroupToAdd))
                {
                    throw new SqlAzManException(String.Format("Cannot add '{0}'. A loop has been detected.", applicationGroupToAdd.Name));
                }
            }
            int retV = this.db.ApplicationGroupMemberInsert(this.applicationGroupId, sid.BinaryValue, (byte)whereDefined, isMember, this.application.ApplicationId);
            IAzManApplicationGroupMember result = new SqlAzManApplicationGroupMember(this.db, this, retV, sid, whereDefined, isMember, this.ens);

            this.raiseApplicationGroupMemberCreated(this, result);
            if (this.ens != null)
            {
                this.ens.AddPublisher(result);
            }
            return(result);
        }
 /// <summary>
 /// Gets the store group members.
 /// </summary>
 /// <returns></returns>
 public IAzManApplicationGroupMember[] GetApplicationGroupNonMembers()
 {
     if (this.groupType != GroupType.Basic)
         throw new InvalidOperationException("Method not supported for LDAP Groups");
     var agnm = (from f in this.db.ApplicationGroupMembers()
                 where
                 (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && f.WhereDefined != (byte)WhereDefined.Local
                 ||
                 this.application.Store.Storage.Mode == NetSqlAzManMode.Developer)
                 &&
                 f.ApplicationGroupId == this.applicationGroupId && f.IsMember == false
                 select f).ToList();
     int index = 0;
     IAzManApplicationGroupMember[] applicationGroupNonMembers = new SqlAzManApplicationGroupMember[agnm.Count];
     foreach (var row in agnm)
     {
         applicationGroupNonMembers[index] = new SqlAzManApplicationGroupMember(this.db, this, row.ApplicationGroupMemberId.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(applicationGroupNonMembers[index]);
         index++;
     }
     return applicationGroupNonMembers;
 }
 /// <summary>
 /// Gets the application group member.
 /// </summary>
 /// <param name="sid">The object owner.</param>
 /// <returns></returns>
 public IAzManApplicationGroupMember GetApplicationGroupMember(IAzManSid sid)
 {
     if (this.groupType != GroupType.Basic)
         throw new InvalidOperationException("Method not supported for LDAP Groups");
     ApplicationGroupMembersResult agm;
     if ((agm = (from t in this.db.ApplicationGroupMembers() where t.ApplicationGroupId == this.applicationGroupId && t.ObjectSid == sid.BinaryValue select t).FirstOrDefault()) != null)
     {
         if (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && agm.WhereDefined == (byte)WhereDefined.Local)
         {
             throw SqlAzManException.ApplicationGroupMemberNotFoundException(sid.StringValue, this, null);
         }
         else
         {
             IAzManApplicationGroupMember result = new SqlAzManApplicationGroupMember(this.db, this, agm.ApplicationGroupMemberId.Value, new SqlAzManSID(agm.ObjectSid.ToArray(), agm.WhereDefined == (byte)(WhereDefined.Database)), (WhereDefined)(agm.WhereDefined), agm.IsMember.Value, this.ens);
             if (this.ens != null) this.ens.AddPublisher(result);
             return result;
         }
     }
     else
     {
         throw SqlAzManException.ApplicationGroupMemberNotFoundException(sid.StringValue, this, null);
     }
 }
        /// <summary>
        /// Creates the application group member.
        /// </summary>
        /// <param name="sid">The object owner.</param>
        /// <param name="whereDefined">The where defined.</param>
        /// <param name="isMember">if set to <c>true</c> [is member].</param>
        public IAzManApplicationGroupMember CreateApplicationGroupMember(IAzManSid sid, WhereDefined whereDefined, bool isMember)
        {
            if (this.groupType != GroupType.Basic)
                throw new InvalidOperationException("Method not supported for LDAP Groups");

            if (this.application.Store.Storage.Mode == NetSqlAzManMode.Administrator && whereDefined == WhereDefined.Local)
            {
                throw new SqlAzManException("Cannot create Application Group members defined on local in Administrator Mode");
            }
            //Loop detection
            if (whereDefined == WhereDefined.Application)
            {
                IAzManApplicationGroup applicationGroupToAdd = this.application.GetApplicationGroup(sid);
                if (this.detectLoop(applicationGroupToAdd))
                    throw new SqlAzManException(String.Format("Cannot add '{0}'. A loop has been detected.", applicationGroupToAdd.Name));
            }
            int retV = this.db.ApplicationGroupMemberInsert(this.applicationGroupId, sid.BinaryValue, (byte)whereDefined, isMember, this.application.ApplicationId);
            IAzManApplicationGroupMember result = new SqlAzManApplicationGroupMember(this.db, this, retV, sid, whereDefined, isMember, this.ens);
            this.raiseApplicationGroupMemberCreated(this, result);
            if (this.ens != null) this.ens.AddPublisher(result);
            return result;
        }