Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kyriakos 2 posts 22 karma points
    May 21, 2015 @ 15:44
    Kyriakos
    0

    Check if Specific Member has Access to Node

    Hello.

    I am looking to share information from Umbraco with another web site. To do this, the other web site must "ask" umbraco which nodes a specific member has access to.

    So, I created an ASHX handler, which I call with username and password. In the ASHX, I validate the credentials and if correct, I have access to the umbraco member, using one of the two following ways:

    Approach 1:

    Dim ms As umbraco.Core.Services.MemberService = ApplicationContext.Current.Services.MemberService
    Dim mbr1 As Member = ms.GetByUsername("username")

    Approach 2:

    Dim ms2 As New umbraco.Web.Security.MembershipHelper(umbraco.Web.UmbracoContext.Current)
    Dim mbr2 As MemberPublishedContent = ms2.GetByUsername("username")

    Now, assume I have a baseNode with id 1278.

    Dim BaseNode As New Node(1278)

    How can I check if my Member (mbr1 or mbr2) has access to BaseNode?

    P.S.: All the approaches I have found so far require that the Member is logged in (via a cookie), the page is reloaded and the check is done by umbraco.library.HasAccess(Nd.Id, Nd.Path). Being a web service - handler, this is not an option. The check must be done in a single call.

    Thank you in advance,

    Kyriakos

  • Charles Afford 1163 posts 1709 karma points
    May 25, 2015 @ 19:27
    Charles Afford
    0

    I don't actually know the answer but my gut is that it will be in the MembershipService. Or the ContentService.

    What version of Umbraco are you using? :)

    Charlie

  • Kyriakos 2 posts 22 karma points
    May 26, 2015 @ 09:25
    Kyriakos
    0

    Hello Charlie.

    I am using version 7.2.4.

    I also assume that the answer is in ContentService, or in Umbraco.Library.

    One lead that I followed was to use with the groups (making the assumption that we Groups -> MemberGroups). Umbraco.library provides a method
    umbraco.library.AllowedGroups(BaseNode.Id, BaseNode.Path) for the node.

    The problem there is that I cannot fetch the groups that the member is in. There exists a property Groups in Umbraco.Core.Model.Member, but getting the member using umbraco.Core.Services.MemberService.GetByUsername("test") returns nothing (even when the user is part of several memberGroups.

    K.

Please Sign in or register to post replies

Write your reply to:

Draft