Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, i am doing a project in vb.net where all the ip addresses in a lan can be displayed.
But i want a code to block a specific ip address in my lan connection.
i hope u can provide me a better solution by giving a .net code which can run in visual studio 2008 version.
Posted
Updated 6-Jan-11 4:43am
v3
Comments
[no name] 6-Jan-11 9:40am    
What do you mean "block a specific ip"? So it doesn't show up in your list?
Prerak Patel 7-Jan-11 2:39am    
If you have done something, share it. We are here to help you with the problem, but no one will give you ready-made code you want.

You can find a lot of examples if you try google[^]
 
Share this answer
 
Comments
Kasson 6-Jan-11 23:52pm    
Good Call. My 5 for you. then only before posting the question they will try something.
Use active directory through System.Management

Here are some info to get you started:
Howto: (Almost) Everything In Active Directory via C#[^]

Regards
Espen Harlinn
 
Share this answer
 
Comments
thatraja 6-Jan-11 11:40am    
Hey, It's a good article, I missed that. 5! :-)
Espen Harlinn 6-Jan-11 12:01pm    
Thanks
Kasson 6-Jan-11 23:51pm    
Nice One My 5 too.
VB
'variable declarations
Dim UserIP as String
Dim flag as Integer = 0
Dim arrayIPs(1) as String
'Assign the blocked IP Addresses in an array
arrayIPs(0) = "127.0.0.01"
arrayIPs(1) = "100.45.76.80"
'get the users IP address
UserIP = Request.ServerVariables("LOCAL_ADDR")
'looping through the banned IP addresses
For i = 0 to arrayIPs.Length-1
'display a message and stop processing the page
If UserIP = arrayIPs(i) Then
flag  = flag + 1
End If
Next
If (flag <> 0) then
MessageBox.Show("You are not an authorized user to access this website")
Else
MessageBox.Show("Valid Users")
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900