Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6374293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:28:11+00:00 2026-05-25T01:28:11+00:00

I’m trying to implement a really really simple MembershipProvider for sitecore, but i’m not

  • 0

I’m trying to implement a really really simple MembershipProvider for sitecore, but i’m not sure if it’s too simple to actually work. Basically we already have a custom store for user data so i know that a customer MembershipProvider is the way to go. However my app will not log anyone in, a different part of the system is responsible for that. Also, it doesn’t care who exactly is logged in, just whether they are or aren’t (the who part is irrelevant in the content area of my site).

So what is the best way to go about this? I am passed a token in the HTTP header which allows me to identify whether someone is logged in or not (i could even use this to actually find out who the customer is if i so wished) – don’t worry it’s encrypted.

I’ve read through the sitecore docs but they all deal with full implementations of MembershipProviders.

So is it possible to actually have a membership provider that does only this i.e. returns either a user to signify being logged or an “anonymous” user for those who are logged out? it need not be concerned with anything else – password reset, look up users by email and all that jazz.

Thanks,
Nick

EDIT: with the help of Jens below i have eschewed a full-blown MembershipProvider in favour of a more lightweight approach.

this is what i have so far, the problem being that users are not kept logged in over multiple requests.

public class TokenLogin : HttpRequestProcessor
{


    #region Overrides of HttpRequestProcessor

    /// <summary>
    /// Processes the specified args.
    /// </summary>
    /// <param name="args">The args.</param>
    public override void Process(HttpRequestArgs args)
    {
        var customer = SomeCodeToParseAndValidateToken();

        //customer is null if token is invalid or missing
        if(customer == null || Sitecore.Context.User.IsAuthenticated) return;

        CreateVirtualUser(customer);
    }

    private static void CreateVirtualUser(CustomerAccount customer)
    {
        string userName = "extranet\\" + customer.CustomerAccountId;

        User userItem = AuthenticationManager.BuildVirtualUser(userName, true);   
        userItem.Profile.Initialize(userName, true);    
        userItem.Profile.Save();

        AuthenticationManager.Login(userItem.Name);
    }

    #endregion
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:28:12+00:00Added an answer on May 25, 2026 at 1:28 am

    Implementing a membershipprovider is a lot of work for what you seem to need. If I were you I would implement a scenario, where you create a virtual user everytime someone needs to be logged in.
    So the logic would be to check if a user has your token, then create a virtual user, log the virtual user in and you should be good to go.

    Here is a guide on the virual user thingie: http://sdn.sitecore.net/Articles/Security/Faking%20user%20roles/Virtual%20user.aspx

    EDIT: The code in the link is depricated. Here is how you add virtual users:

       userName = "extranet\\"+userName    
       User userItem = AuthenticationManager.BuildVirtualUser(userName, true);   
       userItem.Profile.Initialize(userName, true);    
       userItem.Profile.Email = userName + "@yourdomain.com";   
       userItem.Profile.Save();
    
       AuthenticationManager.Login(userItem.Name)
    

    EDIT 2: I have the following code:

        public class TestVirtualUserProcessor : HttpRequestProcessor
        {
    
    
          public override void Process(HttpRequestArgs args)
          {
            HttpContext.Current.Response.Write(Sitecore.Context.User.Name + "<br/>");
            HttpContext.Current.Response.Write(Sitecore.Context.User.IsAuthenticated + "<br/>");
    
            CreateVirtualUser("jenneren");
    
            HttpContext.Current.Response.Write(Sitecore.Context.User.Name + "<br/>");
            HttpContext.Current.Response.Write(Sitecore.Context.User.IsAuthenticated + "<br/>");
            }
    
          private static void CreateVirtualUser(string name)
          {
            string userName = "extranet\\" + name;
    
            User userItem = AuthenticationManager.BuildVirtualUser(userName, true);
            userItem.Profile.Initialize(userName, true);
            userItem.Profile.Save();
    
            AuthenticationManager.Login(userItem.Name);
          }
    
    
        }
    

    This outputs the following the first time I hit the frontend:

    extranet\Anonymous
    False
    extranet\jenneren
    True

    And the second time I hit the frontend I get:

    extranet\jenneren
    True
    extranet\jenneren
    True

    So it should work.
    Cheers
    Jens

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.