如何阻止用户而非所有用户访问网站 [英] how to block website for User not for All User
问题描述
我正在使用此代码屏蔽网站.但它会阻止所有用户访问网站.我想阻止特定用户而不是所有用户访问网站.请建议我该怎么做.任何链接.建议等
我只想阻止系统上所有用户的网站.例如.系统中有两个用户,例如.鲍勃和吉米.我想阻止Bob的"www.facebook.com",而不是Jimmy的阻止.如果Jimmy登录系统,他可以访问"www.facebook.com".但是当Bob登录时,他无法访问.它是一个窗口应用程序.... ...我正在使用下面的代码.但是它阻止了所有用户
I am using this code for blocking website. but it block website for all user. i want to block website for specific user not for all user.please suggest me how to do this. any links. suggestion etc.
I want to block website on system for user only not for all user. For example. There is two user in system e.g . Bob and Jimmy . i want to block "www.facebook.com for Bob. not for Jimmy. If Jimmy log in system he can access "www.facebook.com". but when Bob login he can not access. its a window application.......I am using the below code.but it block for all user
String strpath = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter objstrWri = new StreamWriter(strpath , true);
String siteDtl= "\n 127.0.0.1 google.com";
objstrWri .Write(siteDtl);
objstrWri .Close();
推荐答案
那根本不是C#问题.
一种可能的解决方案是具有用户身份验证的代理服务器.然后可以按所需方式配置代理服务器.
一个更简单的解决方案是代理配置脚本,通常是"proxy.pac".将浏览器配置为从用户特定的位置获取该脚本后,即可获得所需的效果.
proxy.pac脚本类似于
That''s not at all a C# problem.
A possible solution is a proxy server, with user authentication. Then the proxy server can be configured in the desired way.
A simpler solution is a proxy configuration script, typically "proxy.pac". When the browser is configured to take that script from a user-specific location, you can get the desired effect.
The proxy.pac script looks something like
function FindProxyForURL(url, host)
{
if (dnsDomainIs(host, ".facebook.com")) {
return "PROXY 127.0.0.1:80";
}
else {
return "DIRECT";
}
}
这篇关于如何阻止用户而非所有用户访问网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!