TransactionalNodeService.SharePoint.SecurityModel.GlymaSecurityTrimmer.CheckRootMapAuthorisationBaseOnNode C# (CSharp) Method

CheckRootMapAuthorisationBaseOnNode() public method

public CheckRootMapAuthorisationBaseOnNode ( System.Guid domainId, System.Guid nodeId ) : bool
domainId System.Guid
nodeId System.Guid
return bool
        public bool CheckRootMapAuthorisationBaseOnNode(Guid domainId, Guid nodeId, params IRight[] requiredRights)
        {
            using (IDbConnectionAbstraction connectionAbstraction = GlymaSession.ConnectionFactory.CreateMapDbConnection())
            {
                SqlCommand findRootMapIdCommand = BuildFindRootMapIdCommand(connectionAbstraction.Connection, domainId, nodeId);

                connectionAbstraction.Open();
                object rootMapIdQueryResult = findRootMapIdCommand.ExecuteScalar();
                connectionAbstraction.Close();

                if (rootMapIdQueryResult != null && rootMapIdQueryResult != DBNull.Value && rootMapIdQueryResult is Guid)
                {
                    Guid rootMapId = (Guid)rootMapIdQueryResult;

                    return GlymaUser.IsAuthorised(domainId, rootMapId, requiredRights);
                }
                else
                {
                    return GlymaUser.IsAuthorised(domainId, requiredRights);
                }
            }
        }

Usage Example

        public QueryResponse QueryMapPaged(string callingUrl, Guid domainId, Guid nodeId, int maxDepth, EdgeConditions edgeConditions, FilterConditions filterConditions, int objectIndex)
        {
            using (GlymaNSApp.NodeServiceClient nodeServiceClient = new GlymaNSApp.NodeServiceClient(callingUrl))
            {
                /// This method requires security trimming so there is no need to check authentication here.
                using (WebAppSPGlymaSession glymaSession = new WebAppSPGlymaSession(callingUrl))
                {
                    GlymaSessionConfiguration configuration = glymaSession.ExportGlymaSession();

                    /// This method doesn't traverse rootmap boundaries.
                    GlymaSecurityTrimmer securityTrimmer = new GlymaSecurityTrimmer(glymaSession.Web, glymaSession);

                    securityTrimmer.CheckRootMapAuthorisationBaseOnNode(domainId, nodeId, SPGlymaRightFactory.Instance.MapReadRight);

                    QueryResponse response = nodeServiceClient.QueryMapPaged(configuration, domainId, nodeId, maxDepth, edgeConditions, filterConditions, objectIndex);
                    response.CompressResponse();

                    return response;
                }
            }
        }