예제 #1
0
        internal ResponseObject BreakRootMapInheritance(GlymaSecurableObject securableObject)
        {
            ResponseObject response = new ResponseObject()
            {
                HasError = false
            };

            try
            {
                GetSecurableContextIdResponse securableContextIdResponse = GetSecurableContextId();
                if (!securableContextIdResponse.HasError)
                {
                    int                         securableContextId = securableContextIdResponse.Result;
                    SecurableObject             obj = GetSecurableObject(securableContextId, securableObject.SecurableObjectUid);
                    GlymaSecurableObjectContext securableObjectContext = new GlymaSecurableObjectContext(this, securableContextId, securableObject);
                    if (obj == null)
                    {
                        obj = securableObjectContext.CreateSecurableObject(true);
                    }
                    if (!obj.BreaksInheritance)
                    {
                        securableObjectContext.SetSecurableObjectInheritance(true);
                    }
                    CopyGroupAssociationsToRootMap(securableObject);
                }
            }
            catch (Exception ex)
            {
                response.HasError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response);
        }
        internal SecurableObject CreateSecurableObject(bool breaksInheritance)
        {
            SecurableObject createdSecurableObject = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (IGlymaSession glymaSession = new WebAppSPGlymaSession(Context.WebUrl))
                {
                    using (IDbConnectionAbstraction connectionAbstraction = glymaSession.ConnectionFactory.CreateSecurityDbConnection())
                    {
                        using (SecurityServiceDataContext dataContext = new SecurityServiceDataContext(connectionAbstraction.Connection))
                        {
                            SecurableObject securableObject    = new SecurableObject();
                            securableObject.SecurableObjectUid = SecurableObject.SecurableObjectUid;
                            securableObject.BreaksInheritance  = breaksInheritance;
                            securableObject.SecurableContextId = SecurableContextId;
                            dataContext.SecurableObjects.InsertOnSubmit(securableObject);
                            dataContext.SubmitChanges();

                            // Return the group that was created
                            securableObject = (from so in dataContext.SecurableObjects
                                               where so.SecurableObjectUid == SecurableObject.SecurableObjectUid &&
                                               so.SecurableContextId == SecurableContextId
                                               select so).First();
                            createdSecurableObject = securableObject;
                        }
                    }
                }
            });

            return(createdSecurableObject);
        }
예제 #3
0
        internal SecurableObject GetSecurableObject(int securableContextId, Guid securableObjectUid)
        {
            SecurableObject result = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (IGlymaSession glymaSession = new WebAppSPGlymaSession(this.WebUrl))
                {
                    using (IDbConnectionAbstraction connectionAbstraction = glymaSession.ConnectionFactory.CreateSecurityDbConnection())
                    {
                        using (SecurityServiceDataContext dataContext = new SecurityServiceDataContext(connectionAbstraction.Connection))
                        {
                            var securableObjects = from so in dataContext.SecurableObjects
                                                   where so.SecurableObjectUid == securableObjectUid &&
                                                   so.SecurableContextId == securableContextId
                                                   select so;

                            SecurableObject securableObject = null; //default value if it doesn't exist
                            if (securableObjects.Any())
                            {
                                securableObject = securableObjects.First();
                            }
                            result = securableObject;
                        }
                    }
                }
            });
            return(result);
        }
예제 #4
0
        internal GetSecurityAssociationsResponse RestoreRootMapInheritance(GlymaSecurableObject securableObject)
        {
            GetSecurityAssociationsResponse response = new GetSecurityAssociationsResponse()
            {
                HasError = false
            };

            try
            {
                GetSecurableContextIdResponse securableContextIdResponse = GetSecurableContextId();
                if (!securableContextIdResponse.HasError)
                {
                    int                         securableContextId = securableContextIdResponse.Result;
                    SecurableObject             obj = GetSecurableObject(securableContextId, securableObject.SecurableObjectUid);
                    GlymaSecurableObjectContext securableObjectContext = new GlymaSecurableObjectContext(this, securableContextId, securableObject);
                    if (obj == null)
                    {
                        obj = securableObjectContext.CreateSecurableObject(false);
                    }
                    if (obj.BreaksInheritance)
                    {
                        securableObjectContext.SetSecurableObjectInheritance(false);
                    }
                    RemoveRootMapGroupAssociations(securableObject);

                    GlymaSecurableObject parentObject = new GlymaSecurableObject();
                    parentObject.SecurableParentUid = Guid.Empty;
                    parentObject.SecurableObjectUid = securableObject.SecurableParentUid;
                    GetAllSecurityGroupsResponse res = GetAllGlymaSecurityGroups();
                    if (!res.HasError)
                    {
                        IList <GlymaSecurityGroup> groups = ConversionUtility.ConvertDictToList(res.Result);
                        response = GetSecurityAssociations(groups, parentObject);
                    }
                    else
                    {
                        response.HasError     = true;
                        response.ErrorMessage = "Failed returning the Glyma security groups. " + res.ErrorMessage;
                    }
                }
                else
                {
                    response.HasError     = true;
                    response.ErrorMessage = "Failed to restore root map inheritance. " + securableContextIdResponse.ErrorMessage;
                }
            }
            catch (Exception ex)
            {
                response.HasError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response);
        }
예제 #5
0
        /// <summary>
        /// Adds a security association for a SharePoint group to the security DB
        /// </summary>
        /// <param name="breakInheritance">Whether it should have inheritance broken or not</param>
        /// <returns>A response object indicating if completed without error</returns>
        internal ResponseObject SetSecurityAssociation(bool breakInheritance)
        {
            ResponseObject result = new ResponseObject()
            {
                HasError = false
            };

            try
            {
                if (Group != null)
                {
                    Group group = Context.GetGroup(Group);

                    //if (group == null)
                    //{
                    //    //Create the Group since it doesn't exist
                    //    group = this.CreateGroup();

                    //}
                    bool response = this.HasAssociation();
                    if (!response)
                    {
                        SecurableObject             so = Context.GetSecurableObject(Group.SecurableContextId, SecurableObject.SecurableObjectUid);
                        GlymaSecurableObjectContext securableObjectContext = new GlymaSecurableObjectContext(Context, Group.SecurableContextId, SecurableObject);
                        if (so == null)
                        {
                            so = securableObjectContext.CreateSecurableObject(breakInheritance);
                        }

                        //Create the group association since it doesn't exist
                        this.CreateGroupAssociation(group.GroupId);
                    }
                }
                else
                {
                    result.HasError     = true;
                    result.ErrorMessage = "The Glyma security group was not known.";
                }
            }
            catch (Exception ex)
            {
                result.HasError     = true;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        internal bool GetIsInherited()
        {
            bool result = false;

            if (SecurableObject.SecurableParentUid != Guid.Empty)
            {
                SecurableObject securableObject = Context.GetSecurableObject(SecurableContextId, SecurableObject.SecurableObjectUid);
                if (securableObject != null)
                {
                    result = !securableObject.BreaksInheritance;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
 internal void SetSecurableObjectInheritance(bool breaksInheritance)
 {
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
         using (IGlymaSession glymaSession = new WebAppSPGlymaSession(Context.WebUrl))
         {
             using (IDbConnectionAbstraction connectionAbstraction = glymaSession.ConnectionFactory.CreateSecurityDbConnection())
             {
                 using (SecurityServiceDataContext dataContext = new SecurityServiceDataContext(connectionAbstraction.Connection))
                 {
                     SecurableObject securableObject = (from so in dataContext.SecurableObjects
                                                        where so.SecurableObjectUid == SecurableObject.SecurableObjectUid &&
                                                        so.SecurableContextId == SecurableContextId
                                                        select so).First();
                     securableObject.BreaksInheritance = breaksInheritance;
                     dataContext.SubmitChanges();
                 }
             }
         }
     });
 }
예제 #8
0
 private void detach_SecurableObjects(SecurableObject entity)
 {
     this.SendPropertyChanging();
     entity.SecurableContext = null;
 }
예제 #9
0
 partial void DeleteSecurableObject(SecurableObject instance);
예제 #10
0
 partial void UpdateSecurableObject(SecurableObject instance);
예제 #11
0
 partial void InsertSecurableObject(SecurableObject instance);