/// <inheritdoc />
        /// <summary>
        /// Check if user is an (possibly indirect) member of an identity group
        /// </summary>
        /// <param name="body">Method XML body item</param>
        /// <returns>'true' as string result if membership matches</returns>
        public override Item DoApply(Item body)
        {
            XmlPropertyAttribute.BindXml(body.node, this);

            var userId = Innovator.getUserID();

            var userAlias = Innovator.newItem("Alias", "get");

            userAlias.setAttribute("select", "related_id");
            userAlias.setProperty("source_id", userId);
            userAlias = Innovator.ApplyItem(userAlias);

            var identityId = userAlias.getProperty("related_id");

            return(Innovator.newResult(CheckIfMemberOfIdentity(identityId) ? "true" : "false"));
        }
Esempio n. 2
0
        /// <inheritdoc />
        /// <summary>
        /// Check if user is an (possibly indirect) member of an identity group
        /// </summary>
        /// <param name="body">Method XML body item</param>
        /// <returns>'true' as string result if membership matches</returns>
        public override Item DoApply(Item body)
        {
            XmlPropertyAttribute.BindXml(body.node, this);

            var userId = Innovator.getUserID();

            var userAlias = Innovator.newItem("Alias", "get");

            userAlias.setAttribute("select", "related_id");
            userAlias.setProperty("source_id", userId);
            userAlias = Innovator.ApplyItem(userAlias);

            var ids = new List <string> {
                userAlias.getProperty("related_id")
            };

            // not the fastest, but it works.
            // should be optimized by asking for batches of identities.
            // (see below for fast recursive SQL .. that Aras doesn't permit in ApplySQL.)
            while (ids.Any())
            {
                var id = ids.Last();
                ids.RemoveAt(ids.Count - 1);

                var identityItem = Innovator.newItem("Identity", "get");
                identityItem.setAttribute("select", "keyed_name");

                var memberRelation = identityItem.createRelationship("Member", "get");
                memberRelation.setAttribute("select", "keyed_name");
                memberRelation.setProperty("related_id", id);
                identityItem = Innovator.ApplyItem(identityItem);

                if (identityItem.Enumerate()
                    .Any(i => i.getProperty("keyed_name") == IdentityName))
                {
                    return(Innovator.newResult("true"));
                }

                ids.AddRange(identityItem.Enumerate().Select(i => i.getID()));
            }

            return(Innovator.newResult("false"));
        }