How can we determine user role for script in WCM

I want to use a script on an html content record that will determine the logged in users role or member type. The purpose of this is to redirect them to a specific page once they are logged in. The sample Member site has some scripting on the Default page but it is just checking to see that the user is logged in and is not "GUEST". Need to do some additional filtering.

Any assistance would be greatly appreciated!

Thanks, Terry

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

    This information is in

 

 

This information is in the UserRole table - it joins to the UserMain table by the userkey. The UserMain table has the iMIS ID as the ContactMaster field.

 

Example code to Redirect to a page if Member Type is STF (Staff)

 

<script language="C#" runat="server">

 

    protected override void OnInit(EventArgs e)

    {

 

        base.OnInit(e);

        var userId = String.Empty;

        var id = String.Empty;

        var customerType = String.Empty;

 

        if (Asi.Security.AppPrincipal.CurrentIdentity != null)

        {

            userId = Asi.Security.AppPrincipal.CurrentIdentity.UserId;

 

            // Bilal: Determine if its a staff (Member Type = STF) and redirect accordingly

            id = Asi.AppContext.CurrentIdentity.LoginIdentity;

            Asi.Soa.ClientServices.EntityManager entityManager = new Asi.Soa.ClientServices.EntityManager();

            Asi.Soa.ClientServices.MembershipManager membershipManager = new Asi.Soa.ClientServices.MembershipManager(entityManager);

            Asi.Soa.Membership.DataContracts.PartyData party = membershipManager.FindPartyByPartyId(id);

 

            if (Asi.AppContext.CurrentIdentity.IsAuthenticated && userId != "GUEST")

            {

                customerType = (string)party.AdditionalAttributes.GetPropertyValue("CustomerTypeCode");

                if (customerType == "STF")

                {

                    string url = Asi.Web.UI.AsiCommon.Utils.RedirectHelper.GetNewUrl(

                                 new NameValueCollection(Request.QueryString),

                                 Asi.AppContext.CurrentContext.WebsiteKey, "FullAccount");

 

                    Response.Redirect(url);

                }

                else

                {

                    Response.Redirect("~/MemberHome.aspx", false);

                    HttpContext.Current.ApplicationInstance.CompleteRequest();

                    return;

                }

            }

 

        }

 

    }

 

</script>

Do you happen to have the

Do you happen to have the script for doing this using the user role? Thanks so much!

 

Terry Hammond enSYNC Corporation Fort Worth, TX terry@ensync-corp.com

Worked!

Thank you so much for providing this. It will be very useful.

Terry Hammond enSYNC Corporation Fort Worth, TX terry@ensync-corp.com