Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » How to do an IP address validation?

How to do an IP address validation?

Peter Leleulya
Reply

I have enriched the dynamicweb user with a field for an IP address.
Preferably I would like to hook in before the user gets logged in and return a custom error message, but I don't see how.

Now I've added an OnExtranetLoginObserver in which I retrieve the IP address value of the user logging in and compare it to its current IP.
If they do not match I would like to log-off and redirect to a login page with a parameter so I can show an error message.

I used to use this, but this is no longer available:
var sec = new Dynamicweb.Security();
sec.ExtranetLogoff(false);


I've now tried this, but this crashes:
var loginHandler = new Dynamicweb.Frontend.LoginHandler();
loginHandler.ExtranetLogoff(false);

Can anyone tell me how to best achieve my goal?
 


Replies

 
Peter Leleulya
Reply
This post has been marked as an answer

Never mind, I found the OnBeforeExtranetLogin notification subscriber

Votes for this answer: 1
 
Jan Sangill
Reply

Hi Peter,

In this method: OnBeforeExtranetLogin

How do you get the current IP when HttpContext.Current is null?

//jan

 
Martin Vang
Martin Vang
Reply

Hi Jan,

HttpContext.Current should not be null when this notification fires, so we need some more information

Please make a new thread for your question. :)

BR

Martin

 

You must be logged in to post in the forum