Glyma.SharePoint.Security.GlymaSecurableObjectContext.CreateSecurableObject C# (CSharp) Method

CreateSecurableObject() private method

private CreateSecurableObject ( bool breaksInheritance ) : SecurableObject
breaksInheritance bool
return SecurableObject
        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;
        }
    }

Usage Example

コード例 #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);
        }
All Usage Examples Of Glyma.SharePoint.Security.GlymaSecurableObjectContext::CreateSecurableObject