Exemplo n.º 1
0
        public GetIsUserGlymaSecurityManagerResponse GetIsUserGlymaSecurityManager(string webUrl)
        {
            GetIsUserGlymaSecurityManagerResponse response = new GetIsUserGlymaSecurityManagerResponse()
            {
                HasError = false
            };
            bool result = false;

            try
            {
                SecurityContextManager contextManager = new SecurityContextManager(webUrl);
                result = contextManager.CurrentUser.IsUserSecurityManager();
            }
            catch (Exception ex)
            {
                response.HasError     = true;
                response.ErrorMessage = "Failed to discover if the current user is a Glyma Security Manager. " + ex.Message;
            }
            if (!response.HasError)
            {
                response.Result = result;
            }

            return(response);
        }
 public GlymaSecurityGroupContext(SecurityContextManager context, int securableContextId, int spGroupId, Guid webId)
 {
     Context = context;
     SPGroupId = spGroupId;
     WebId = webId;
     SecurableContextId = securableContextId;
 }
 public GlymaSecurityGroupContext(SecurityContextManager context, int securableContextId, int spGroupId, Guid webId)
 {
     Context            = context;
     SPGroupId          = spGroupId;
     WebId              = webId;
     SecurableContextId = securableContextId;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the security context id from the URL of the current site
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <returns>The SecurityContextId or -1 if it wasn't found (wrapped in a response object to indicate if it completed without error)</returns>
        public GetSecurableContextIdResponse GetSecurableContextId(string webUrl)
        {
            GetSecurableContextIdResponse result = new GetSecurableContextIdResponse()
            {
                HasError = false
            };
            SecurityContextManager securityContext = new SecurityContextManager(webUrl);

            result = securityContext.GetSecurableContextId();
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the current security associations for a list of groups against a particular securable object
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="groups">A list of groups to get the security assocations for</param>
        /// <param name="securableObject">An object that contains the Parent and Object ID's
        ///                                 SecurableParentUid: The ID of the securable parent (Guid.Empty for projects),
        ///                                 SecurableObjectUid: The ID of the securable object (root map UID or project UID if securing a project)</param>
        /// <returns>A dictionary of security association, Key: the group, Value: True if the group has an assocation. (wrapped in a Response Object to indicate if any errors occured)</returns>
        public GetSecurityAssociationsResponse GetSecurityAssociations(string webUrl, IEnumerable <GlymaSecurityGroup> groups, GlymaSecurableObject securableObject)
        {
            GetSecurityAssociationsResponse result = new GetSecurityAssociationsResponse()
            {
                HasError = false
            };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);

            result = securityContext.GetSecurityAssociations(groups, securableObject);
            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the highest permission (role) name that the current user has if they have access to the object
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securableObject">An object that contains the Parent and Object ID's
        ///                                 SecurableParentUid: The ID of the securable parent (Guid.Empty for projects),
        ///                                 SecurableObjectUid: The ID of the securable object (root map UID or project UID if securing a project)</param>
        /// <returns>The Glyma permission level name if the user has access or null if the user doens't have access</returns>
        public GetPermissionLevelResponse GetPermissionLevelForObject(string webUrl, GlymaSecurableObject securableObject)
        {
            GetPermissionLevelResponse result = new GetPermissionLevelResponse()
            {
                HasError = false
            };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);

            if (securityContext.CurrentUser.IsUserMapReader())
            {
                GlymaPermissionLevel highestPermissionLevel = GlymaPermissionLevel.None;
                try
                {
                    GetCurrentUserAccessToObjectResponse response = securityContext.CurrentUser.GetCurrentUserAccessToObject(securableObject, false);
                    if (!response.HasError)
                    {
                        if (response.HasAccess)
                        {
                            //if the user has access to the object (project or root map) get there highest permission level
                            highestPermissionLevel = response.HighestPermissionLevel;
                        }
                        else
                        {
                            //The user has no access
                            result.Result = GlymaPermissionLevel.None;
                        }
                    }
                    else
                    {
                        result.HasError     = true;
                        result.ErrorMessage = response.ErrorMessage;
                    }
                }
                catch (Exception ex)
                {
                    result.HasError     = true;
                    result.ErrorMessage = ex.Message;
                }
                if (!result.HasError)
                {
                    result.Result = highestPermissionLevel;
                }
            }
            else
            {
                result.HasError     = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service method.";
            }
            return(result);
        }
Exemplo n.º 7
0
        public GetAllSecurityGroupsResponse GetAllSecurityGroups(string webUrl)
        {
            GetAllSecurityGroupsResponse result = new GetAllSecurityGroupsResponse() { HasError = false };
            SecurityContextManager context = new SecurityContextManager(webUrl);
            if (context.CurrentUser.IsUserSecurityManager())
            {
                result = context.GetAllGlymaSecurityGroups();
            }
            else
            {
                result.HasError = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service method.";
            }

            return result;
        }
Exemplo n.º 8
0
        public GetSecurityAssociationsResponse RestoreRootMapInheritance(string webUrl, GlymaSecurableObject securableObject)
        {
            GetSecurityAssociationsResponse result = new GetSecurityAssociationsResponse()
            {
                HasError = false
            };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.RestoreRootMapInheritance(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError     = true;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 9
0
        public ResponseObject BreakRootMapInheritance(string webUrl, GlymaSecurableObject securableObject)
        {
            ResponseObject result = new ResponseObject()
            {
                HasError = false
            };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.BreakRootMapInheritance(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError     = true;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This method is called by a Glyma Project Manager when they create a new project, it will associate any Glyma Project Manager group the user belongs to
        /// with the newly created project.
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securableObject">Describes the project that was just added</param>
        /// <returns>A response object indicating if the operation completed without error.</returns>
        public ResponseObject SetProjectManagerGroupAssociations(string webUrl, GlymaSecurableObject securableObject)
        {
            ResponseObject result = new ResponseObject()
            {
                HasError = false
            };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.CurrentUser.SetProjectManagerGroupAssociations(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError     = true;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 11
0
        public GetAllSecurityGroupsResponse GetAllSecurityGroups(string webUrl)
        {
            GetAllSecurityGroupsResponse result = new GetAllSecurityGroupsResponse()
            {
                HasError = false
            };
            SecurityContextManager context = new SecurityContextManager(webUrl);

            if (context.CurrentUser.IsUserSecurityManager())
            {
                result = context.GetAllGlymaSecurityGroups();
            }
            else
            {
                result.HasError     = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service method.";
            }

            return(result);
        }
Exemplo n.º 12
0
        public GetIsUserGlymaSecurityManagerResponse GetIsUserGlymaSecurityManager(string webUrl)
        {
            GetIsUserGlymaSecurityManagerResponse response = new GetIsUserGlymaSecurityManagerResponse() { HasError = false };
            bool result = false;
            try 
            {
                SecurityContextManager contextManager = new SecurityContextManager(webUrl);
                result = contextManager.CurrentUser.IsUserSecurityManager();
            }
            catch (Exception ex) 
            {
                response.HasError = true;
                response.ErrorMessage = "Failed to discover if the current user is a Glyma Security Manager. " + ex.Message;
            }
            if (!response.HasError)
            {
                response.Result = result;
            }

            return response;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the highest permission level that a user has
        /// </summary>
        /// <param name="webUrl"></param>
        /// <returns></returns>
        public GetPermissionLevelResponse GetUsersPermissionLevel(string webUrl)
        {
            GetPermissionLevelResponse result = new GetPermissionLevelResponse()
            {
                HasError = false
            };
            GlymaPermissionLevel permissionLevel = GlymaPermissionLevel.None;

            GetIsUserGlymaSecurityManagerResponse isSecurityManager = GetIsUserGlymaSecurityManager(webUrl);

            if (!isSecurityManager.HasError)
            {
                if (isSecurityManager.Result)
                {
                    permissionLevel = GlymaPermissionLevel.GlymaSecurityManager;
                    result.Result   = permissionLevel;
                }
                else
                {
                    try
                    {
                        SecurityContextManager context    = new SecurityContextManager(webUrl);
                        IGlymaPermission       permission = context.CurrentUser.GetHighestPermissionLevel();
                        permissionLevel = permission.PermissionLevel;
                        result.Result   = permissionLevel;
                    }
                    catch (Exception e)
                    {
                        result.HasError     = true;
                        result.ErrorMessage = e.Message;
                    }
                }
            }
            else
            {
                result.HasError     = true;
                result.ErrorMessage = isSecurityManager.ErrorMessage;
            }
            return(result);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds or Removes security associations for a batch of groups.
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securityAssociations">The details of the group and the securable object and whether it's an add or remove operation</param>
        /// <returns>A response object to indicate if it completd without error.</returns>
        public ResponseObject UpdateSecurityAssociations(string webUrl, IList <GlymaSecurityAssociation> securityAssociations)
        {
            ResponseObject result = new ResponseObject()
            {
                HasError = false
            };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);

            if (securityContext.CurrentUser.IsUserSecurityManager())
            {
                try
                {
                    foreach (GlymaSecurityAssociation securityAssociation in securityAssociations)
                    {
                        GlymaSecurityAssociationContext securityAssociationContext = new GlymaSecurityAssociationContext(securityContext, securityAssociation.GlymaSecurityGroup, securityAssociation.SecurableObject);
                        if (securityAssociation.Value)
                        {
                            securityAssociationContext.SetSecurityAssociation(securityAssociation.BreakInheritance);
                        }
                        else
                        {
                            securityAssociationContext.RemoveSecurityAssociation();
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.HasError     = true;
                    result.ErrorMessage = ex.Message;
                }
            }
            else
            {
                result.HasError     = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service.";
            }
            return(result);
        }
 internal GlymaSecurableObjectContext(SecurityContextManager context, int securableContextId, GlymaSecurableObject securableObject)
 {
     SecurableContextId = securableContextId;
     SecurableObject    = securableObject;
     Context            = context;
 }
Exemplo n.º 16
0
 internal GlymaSecurityAssociationContext(SecurityContextManager context, GlymaSecurityGroup group, GlymaSecurableObject securableObject)
 {
     Group           = group;
     SecurableObject = securableObject;
     Context         = context;
 }
Exemplo n.º 17
0
 public GlymaSecurityManager(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
Exemplo n.º 18
0
        public ResponseObject BreakRootMapInheritance(string webUrl, GlymaSecurableObject securableObject)
        {
            ResponseObject result = new ResponseObject() { HasError = false };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.BreakRootMapInheritance(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.ErrorMessage = ex.Message;
            }
            return result;
        }
Exemplo n.º 19
0
 public GlymaMapAuthor(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
Exemplo n.º 20
0
        /// <summary>
        /// Gets the current security associations for a list of groups against a particular securable object
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="groups">A list of groups to get the security assocations for</param>
        /// <param name="securableObject">An object that contains the Parent and Object ID's 
        ///                                 SecurableParentUid: The ID of the securable parent (Guid.Empty for projects), 
        ///                                 SecurableObjectUid: The ID of the securable object (root map UID or project UID if securing a project)</param>
        /// <returns>A dictionary of security association, Key: the group, Value: True if the group has an assocation. (wrapped in a Response Object to indicate if any errors occured)</returns>
        public GetSecurityAssociationsResponse GetSecurityAssociations(string webUrl, IEnumerable<GlymaSecurityGroup> groups, GlymaSecurableObject securableObject)
        {
            GetSecurityAssociationsResponse result = new GetSecurityAssociationsResponse() { HasError = false };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);
            result = securityContext.GetSecurityAssociations(groups, securableObject);
            return result;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Gets the security context id from the URL of the current site
 /// </summary>
 /// <param name="webUrl">The URL for the SP site</param>
 /// <returns>The SecurityContextId or -1 if it wasn't found (wrapped in a response object to indicate if it completed without error)</returns>
 public GetSecurableContextIdResponse GetSecurableContextId(string webUrl)
 {
     GetSecurableContextIdResponse result = new GetSecurableContextIdResponse() { HasError = false };
     SecurityContextManager securityContext = new SecurityContextManager(webUrl);
     result = securityContext.GetSecurableContextId();
     return result;
 }
Exemplo n.º 22
0
 public GlymaMapReader(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
Exemplo n.º 23
0
 internal GlymaSecurityAssociationContext(SecurityContextManager context, GlymaSecurableObject securableObject)
 {
     Context         = context;
     SecurableObject = securableObject;
 }
Exemplo n.º 24
0
 public GlymaProjectManager(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
Exemplo n.º 25
0
 public GlymaPermissionFactory(SecurityContextManager context)
 {
     Context = context;
 }
Exemplo n.º 26
0
 public GlymaPermissionFactory(SecurityContextManager context)
 {
     Context = context;
 }
Exemplo n.º 27
0
 public GlymaUserContext(SecurityContextManager context)
 {
     _contextManager = context;
 }
 internal GlymaSecurityAssociationContext(SecurityContextManager context, GlymaSecurityGroup group, GlymaSecurableObject securableObject)
 {
     Group = group;
     SecurableObject = securableObject;
     Context = context;
 }
Exemplo n.º 29
0
        /// <summary>
        /// Adds or Removes security associations for a batch of groups.
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securityAssociations">The details of the group and the securable object and whether it's an add or remove operation</param>
        /// <returns>A response object to indicate if it completd without error.</returns>
        public ResponseObject UpdateSecurityAssociations(string webUrl, IList<GlymaSecurityAssociation> securityAssociations)
        {
            ResponseObject result = new ResponseObject() { HasError = false };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);
            if (securityContext.CurrentUser.IsUserSecurityManager())
            {
                try
                {
                    foreach (GlymaSecurityAssociation securityAssociation in securityAssociations)
                    {
                        GlymaSecurityAssociationContext securityAssociationContext = new GlymaSecurityAssociationContext(securityContext, securityAssociation.GlymaSecurityGroup, securityAssociation.SecurableObject);
                        if (securityAssociation.Value)
                        {
                            securityAssociationContext.SetSecurityAssociation(securityAssociation.BreakInheritance);
                        }
                        else
                        {
                            securityAssociationContext.RemoveSecurityAssociation();
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.HasError = true;
                    result.ErrorMessage = ex.Message;
                }
            }
            else
            {
                result.HasError = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service.";
            }
            return result;
        }
 internal GlymaSecurityAssociationContext(SecurityContextManager context, GlymaSecurableObject securableObject)
 {
     Context = context;
     SecurableObject = securableObject;
 }
Exemplo n.º 31
0
        /// <summary>
        /// Gets the highest permission (role) name that the current user has if they have access to the object
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securableObject">An object that contains the Parent and Object ID's 
        ///                                 SecurableParentUid: The ID of the securable parent (Guid.Empty for projects), 
        ///                                 SecurableObjectUid: The ID of the securable object (root map UID or project UID if securing a project)</param>
        /// <returns>The Glyma permission level name if the user has access or null if the user doens't have access</returns>
        public GetPermissionLevelResponse GetPermissionLevelForObject(string webUrl, GlymaSecurableObject securableObject)
        {
            GetPermissionLevelResponse result = new GetPermissionLevelResponse() { HasError = false };

            SecurityContextManager securityContext = new SecurityContextManager(webUrl);
            if (securityContext.CurrentUser.IsUserMapReader())
            {
                GlymaPermissionLevel highestPermissionLevel = GlymaPermissionLevel.None;
                try
                {
                    GetCurrentUserAccessToObjectResponse response = securityContext.CurrentUser.GetCurrentUserAccessToObject(securableObject, false);
                    if (!response.HasError)
                    {
                        if (response.HasAccess)
                        {
                            //if the user has access to the object (project or root map) get there highest permission level
                            highestPermissionLevel = response.HighestPermissionLevel;
                        }
                        else
                        {
                            //The user has no access
                            result.Result = GlymaPermissionLevel.None;
                        }
                    }
                    else
                    {
                        result.HasError = true;
                        result.ErrorMessage = response.ErrorMessage;
                    }
                }
                catch (Exception ex)
                {
                    result.HasError = true;
                    result.ErrorMessage = ex.Message;
                }
                if (!result.HasError)
                {
                    result.Result = highestPermissionLevel;
                }
            }
            else
            {
                result.HasError = true;
                result.ErrorMessage = "Access Denied. User does not have permissions to access this web service method.";
            }
            return result;
        }
 public GlymaSecurityGroupCollection(SecurityContextManager context, IDictionary<GlymaPermissionLevel, IList<GlymaSecurityGroup>> groups) 
 {
     _groups = groups;
     Context = context;
 }
Exemplo n.º 33
0
        /// <summary>
        /// This method is called by a Glyma Project Manager when they create a new project, it will associate any Glyma Project Manager group the user belongs to
        /// with the newly created project.
        /// </summary>
        /// <param name="webUrl">The URL for the SP site</param>
        /// <param name="securableObject">Describes the project that was just added</param>
        /// <returns>A response object indicating if the operation completed without error.</returns>
        public ResponseObject SetProjectManagerGroupAssociations(string webUrl, GlymaSecurableObject securableObject)
        {
            ResponseObject result = new ResponseObject() { HasError = false };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.CurrentUser.SetProjectManagerGroupAssociations(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.ErrorMessage = ex.Message;
            }
            return result;
        }
Exemplo n.º 34
0
 public GlymaProjectManager(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
Exemplo n.º 35
0
        public GetSecurityAssociationsResponse RestoreRootMapInheritance(string webUrl, GlymaSecurableObject securableObject)
        {
            GetSecurityAssociationsResponse result = new GetSecurityAssociationsResponse() { HasError = false };

            try
            {
                SecurityContextManager context = new SecurityContextManager(webUrl);
                result = context.RestoreRootMapInheritance(securableObject);
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.ErrorMessage = ex.Message;
            }
            return result;
        }
Exemplo n.º 36
0
 public GlymaSecurityGroupCollection(SecurityContextManager context, IDictionary <GlymaPermissionLevel, IList <GlymaSecurityGroup> > groups)
 {
     _groups = groups;
     Context = context;
 }
Exemplo n.º 37
0
 /// <summary>
 /// Gets the highest permission level that a user has
 /// </summary>
 /// <param name="webUrl"></param>
 /// <returns></returns>
 public GetPermissionLevelResponse GetUsersPermissionLevel(string webUrl)
 {
     GetPermissionLevelResponse result = new GetPermissionLevelResponse() { HasError = false };
     GlymaPermissionLevel permissionLevel = GlymaPermissionLevel.None;
     
     GetIsUserGlymaSecurityManagerResponse isSecurityManager = GetIsUserGlymaSecurityManager(webUrl);
     if (!isSecurityManager.HasError)
     {
         if (isSecurityManager.Result)
         {
             permissionLevel = GlymaPermissionLevel.GlymaSecurityManager;
             result.Result = permissionLevel;
         }
         else
         {
             try
             {
                 SecurityContextManager context = new SecurityContextManager(webUrl);
                 IGlymaPermission permission = context.CurrentUser.GetHighestPermissionLevel();
                 permissionLevel = permission.PermissionLevel;
                 result.Result = permissionLevel;
             }
             catch (Exception e)
             {
                 result.HasError = true;
                 result.ErrorMessage = e.Message;
             }
         }
     }
     else
     {
         result.HasError = true;
         result.ErrorMessage = isSecurityManager.ErrorMessage;
     }
     return result;
 }
Exemplo n.º 38
0
 public GlymaUserContext(SecurityContextManager context)
 {
     _contextManager = context;
 }
Exemplo n.º 39
0
 public GlymaMapManager(SecurityContextManager context)
 {
     SecurityContextManager = context;
 }
 internal GlymaSecurableObjectContext(SecurityContextManager context, int securableContextId, GlymaSecurableObject securableObject)
 {
     SecurableContextId = securableContextId;
     SecurableObject = securableObject;
     Context = context;
 }