示例#1
0
        /// <summary>
        /// Function to check user manage permission on document library
        /// </summary>
        /// <param name="refreshToken">The refresh token for Client Context</param>
        /// <param name="clientUrl">The client URL for Client Context</param>
        /// <param name="matterName">Document library name</param>
        /// <param name="request">The HTTP request</param>
        /// <returns>A Boolean variable indicating whether user has manage permission on the matter</returns>
        public static bool CheckUserManagePermission(string refreshToken, Uri clientUrl, string matterName, HttpRequest request)
        {
            bool result = false;

            try
            {
                if (null != request)
                {
                    using (ClientContext clientContext = ServiceUtility.GetClientContext(null, clientUrl, refreshToken, request))
                    {
                        result = Lists.CheckPermissionOnList(clientContext, matterName, PermissionKind.ManagePermissions);
                    }
                }
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// Gets the user access.
        /// </summary>
        /// <param name="refreshToken">The refresh token for Client Context</param>
        /// <param name="clientUrl">The client URL for Client Context</param>
        /// <param name="request">The HTTP request.</param>
        /// <param name="environment">environment identifier</param>
        /// <returns>User has access</returns>
        public static bool GetUserAccess(string refreshToken, Uri clientUrl, HttpRequest request)
        {
            bool flag = false;

            if (request != null)
            {
                try
                {
                    using (ClientContext clientContext = ServiceUtility.GetClientContext(null, clientUrl, refreshToken, request))
                    {
                        flag = Lists.CheckPermissionOnList(clientContext, ConstantStrings.SendMailListName, PermissionKind.EditListItems);
                    }
                }
                catch (Exception exception)
                {
                    Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ConstantStrings.LogTableName);
                    throw;
                }
            }

            return(flag);
        }
 /// <summary>
 /// Validates the inputs for matter provision app and returns the validation status (success/failure).
 /// </summary>
 /// <param name="requestObject">Request Object containing SharePoint App Token</param>
 /// <param name="client">Client object containing Client data</param>
 /// <param name="clientContext">Client context object for SharePoint</param>
 /// <param name="matter">Matter object containing Matter data</param>
 /// <param name="matterDetails">Matter details object which has data of properties to be stamped</param>
 /// <param name="methodNumber">Number indicating which method needs to be validated</param>
 /// <returns>A string value indicating whether validations passed or fail</returns>
 internal static string ProvisionMatterValidation(RequestObject requestObject, Client client, ClientContext clientContext, Matter matter, MatterDetails matterDetails, int methodNumber, MatterConfigurations matterConfigurations)
 {
     if (int.Parse(ConstantStrings.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) <= methodNumber && int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) >= methodNumber && !Lists.CheckPermissionOnList(ServiceUtility.GetClientContext(null, new Uri(ConstantStrings.ProvisionMatterAppURL), requestObject.RefreshToken), ConstantStrings.SendMailListName, PermissionKind.EditListItems))
     {
         return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.IncorrectInputUserAccessMessage));
     }
     else
     {
         if (null != requestObject)
         {
             if (string.IsNullOrWhiteSpace(requestObject.RefreshToken) && string.IsNullOrWhiteSpace(requestObject.SPAppToken))
             {
                 return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputRequestObjectCode, TextConstants.IncorrectInputRequestObjectMessage));
             }
         }
         if (null != client)
         {
             string result = ValidateClientInformation(client, methodNumber);
             if (!string.IsNullOrEmpty(result))
             {
                 return(result);
             }
         }
         if (null != matter)
         {
             string MatterMetadataValidationResponse = MatterMetadataValidation(matter, clientContext, methodNumber, matterConfigurations);
             if (!string.IsNullOrEmpty(MatterMetadataValidationResponse))
             {
                 return(MatterMetadataValidationResponse);
             }
             if (int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber)
             {
                 string roleCheck = ValidationHelperFunctions.RoleCheck(requestObject, matter, client);
                 if (!string.IsNullOrEmpty(roleCheck))
                 {
                     return(roleCheck);
                 }
             }
             if (null != matter.Permissions)
             {
                 bool isFullControlPresent = EditMatterHelperFunctions.ValidateFullControlPermission(matter);
                 if (!isFullControlPresent)
                 {
                     return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.ErrorEditMatterMandatoryPermission));
                 }
             }
         }
         if (null != matterDetails && !(int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber))
         {
             if (string.IsNullOrWhiteSpace(matterDetails.PracticeGroup))
             {
                 return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputPracticeGroupCode, TextConstants.IncorrectInputPracticeGroupMessage));
             }
             if (string.IsNullOrWhiteSpace(matterDetails.AreaOfLaw))
             {
                 return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputAreaOfLawCode, TextConstants.IncorrectInputAreaOfLawMessage));
             }
             if (string.IsNullOrWhiteSpace(matterDetails.SubareaOfLaw))
             {
                 return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputSubareaOfLawCode, TextConstants.IncorrectInputSubareaOfLawMessage));
             }
             try
             {
                 if (string.IsNullOrWhiteSpace(matterDetails.ResponsibleAttorney))
                 {
                     return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputResponsibleAttorneyCode, TextConstants.IncorrectInputResponsibleAttorneyMessage));
                 }
                 else
                 {
                     IList <string> userNames = matterDetails.ResponsibleAttorney.Split(';').ToList <string>();
                     SharePointHelper.ResolveUserNames(clientContext, userNames).FirstOrDefault();
                 }
             }
             catch (Exception)
             {
                 return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputResponsibleAttorneyCode, TextConstants.IncorrectInputResponsibleAttorneyMessage));
             }
         }
     }
     return(string.Empty);
 }