Site structure
Version 5.x > Site structure > no need for login for specific IP-adress View modes: 
User avatar
Member
Member
merete-grape - 3/27/2012 3:22:36 AM
   
no need for login for specific IP-adress
Is it an easy way to set up no need for login for specific ip-adress?

We will have no login for computers accessing for one location.

Is this possible?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/27/2012 4:19:25 AM
   
RE:no need for login for specific IP-adress
Hi,

you could modify the default log-in page. The IP address of visitor is available in the request.

In case it is the one you need, you could authenticate the user. Because visitor comes to the site as anonymous, you would need to authenticate one common user which would be used for authentication and everybody from that one PC would use it.


CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);
CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(System.Web.HttpContext.Current.Session.Timeout), false);

// Ensure response (authentication) cookie
FormsAuthentication.SetAuthCookie(user.UserName, true);


Best regards,
Ivana Tomanickova

User avatar
Member
Member
merete-grape - 3/28/2012 4:11:00 PM
   
RE:no need for login for specific IP-adress
Is this code supposed to be in the membership/logonminiform.ascx.cs-file?

Best regards,
Merete

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/29/2012 8:30:02 AM
   
RE:no need for login for specific IP-adress
Hi,

it is better to clone web part and do not modify the code of standard web part. It will prevents future problems with hotfix.

The mini logon form web part itself authenticate user after he submit his name and password. According to your description you need to check the IP address from which the request comes from and based on in authenticate the user. Therefore you may modify the web part in way:


if (RequestIP=x.x.x.x)
{
// authenticate special common user using provided API
}else
{
// execute code of standard web part
{


Best regards,
Ivana Tomanickova