0

Good Day,

I would like to ask regarding on Redirect or need to login first?

I have a Link on Homepage that if the user click that it will check if the user is logon or not if not then it will redirect on Login page?

Your Response is Highly Appreciated.

EOS

4
Contributors
6
Replies
29
Views
4 Years
Discussion Span
Last Post by ggamble
0

Good Day,

Forget to say im using and Active Directory Authentication

Thank you for your Response

0

I have already this Mr. Vishal, i have already an authentication login/logout parameters but the problem is on the linking authentications. if the user click the link and not yet logon, it will redirect on logon page so he can proceed further.

EOS

Edited by eos.paks

0

Have You seen this article I have mentioned above..
http://msdn.microsoft.com/en-us/library/ms180890%28v=vs.80%29.aspx

In that article they are throwing some error if the user is not authenticated..

    public bool IsAuthenticated(string domain, string username, string pwd)
    {
      string domainAndUsername = domain + @"\" + username;
      DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);

      try
      {
        //Bind to the native AdsObject to force authentication.
        object obj = entry.NativeObject;

        DirectorySearcher search = new DirectorySearcher(entry);

        search.Filter = "(SAMAccountName=" + username + ")";
        search.PropertiesToLoad.Add("cn");
        SearchResult result = search.FindOne();

        if(null == result)
        {
          return false;
        }

        //Update the new path to the user in the directory.
        _path = result.Path;
        _filterAttribute = (string)result.Properties["cn"][0];
      }
      catch (Exception ex)
      {
        throw new Exception("Error authenticating user. " + ex.Message);
      }

      return true;
    }

In place of throw new Exception("Error authenticating user. " + ex.Message); You can use Response.Redirect("Login.aspx",false); so that it will redirect the user to the login page if the users are not authenticated .. Use this code in Linkbutton click event..

0

Only time you should redirect to a login page is if the user clicks a link to go there, or they've bookmarked a page that requires them to be authenticated. If they're just viewing public pages, then there is no reason to have a user login.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.