More in this section
Forums / Bugs & Issues / Bypass login with valid IP address

Bypass login with valid IP address

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. for
    for avatar
    1 posts
    25 Mar 2011
    29 Mar 2011
    Link to this post
    Hi there:

    How can I bypass the login page for some internal users who have certain fixed IP? For other users, they have to sign in? I am totally new to sitefinity. I can't find login.aspx in my project. I have tested the following code. It works. I need to know where I can plug in the code. Please help.

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim strClientIP As String
    Dim IPArray() As String
    Dim matching As Boolean
    matching =
    Dim ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    If (IsNothing(ip)) Then ip = Request.ServerVariables("REMOTE_ADDR")
    IPArray() = Split(ip,
    If IPArray(0) = "???" And IPArray(1) = "???" And IPArray(2) = "???" Then matching = True
    If matching Then
    Response.Write(ip +
    "Bypass the login")
    Response.Write(ip +
    "Need Login")
    End If
    End Sub

    Best regards,

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    31 Mar 2011
    Link to this post
    Hello nick,

    This post shows how to authenticate a user

    Ivan Dimitrov
    the Telerik team
  3. Susan
    Susan avatar
    42 posts
    27 Jul 2009
    24 Jun 2011
    Link to this post
    Thanks for the link to the other post. I've got things working to bypass the login screen but I'm getting stuck on what I think is a very trivial thing. In this bit of code you are passing a hard coded username, "admin". I want to pass a variable instead, such as a querystring. I can't seem to figure out how to get that in there without generating an error.

    MembershipUser user = UserManager.Default.MembershipProvider.GetUser("admin", false);
    FormsAuthentication.SetAuthCookie(user.UserName, true);
    var authCookie = FormsAuthentication.GetAuthCookie(user.UserName, true);
    var ticket = FormsAuthentication.Decrypt(authCookie.Value);
    var identity = new FormsIdentity(ticket);
    Context.User = new RolePrincipal(identity);

    I tried things such as:

    string passeduser = Request.QueryString["PassedUserName"];
    MembershipUser user = UserManager.Default.MembershipProvider.GetUser(passeduser, false);

    but that generates System.NullReferenceException: Object reference not set to an instance of an object.

    Any tips? Thanks!
  4. Susan
    Susan avatar
    42 posts
    27 Jul 2009
    24 Jun 2011
    Link to this post
    D'oh! I got it. I knew it was something stupid. I got so stuck on the harder parts, I missed the simple one. I was checking for a QueryString instead of a Form variable. Amazing how the simple post vs get tripped me up! Thanks!
Register for webinar
4 posts, 0 answered