阻止IP地址的代码 [英] code to block an ip address
本文介绍了阻止IP地址的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在vb.net中做一个项目,可以显示局域网中的所有IP地址。
但是我想要一个代码来阻止我的局域网连接中的特定IP地址。
i希望你能通过提供一个可以在visual studio 2008版本中运行的.net代码为我提供更好的解决方案。
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.
推荐答案
你可以如果您尝试 google [ ^ ]
You can find a lot of examples if you try google[^]
通过System.Management使用活动目录
以下是一些可以帮助您入门的信息:
Howto :(差不多)通过C#在Active Directory中的所有内容[ ^ ]
问候
Espen Harlinn
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
'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
这篇关于阻止IP地址的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文