以上就是给各位分享使用Python和urllib2的Windows身份验证,其中也会对python身份验证程序进行解释,同时本文还将给你拓展ASP.NETMVCUrls和IIS集成Windows身份验
以上就是给各位分享使用Python和urllib2的Windows身份验证,其中也会对python身份验证程序进行解释,同时本文还将给你拓展ASP.NET MVC Urls和IIS集成Windows身份验证、asp.net – iis7中的windows身份验证、asp.net – MVC 3中的Windows身份验证、asp.net – Windows 7中Safari 5.x的Windows身份验证问题等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- 使用Python和urllib2的Windows身份验证(python身份验证程序)
- ASP.NET MVC Urls和IIS集成Windows身份验证
- asp.net – iis7中的windows身份验证
- asp.net – MVC 3中的Windows身份验证
- asp.net – Windows 7中Safari 5.x的Windows身份验证问题
使用Python和urllib2的Windows身份验证(python身份验证程序)
我想从需要Windows用户名和密码的网页上获取一些数据。
到目前为止,我已经:
opener = build_opener()
try:
page = opener.open("http://somepagewhichneedsmywindowsusernameandpassword/")
print page
except URLError:
print "Oh noes."
urllib2支持吗?我找到了Python NTLM,但是这需要我输入用户名和密码。有什么方法可以以某种方式获取身份验证信息(例如,如果更改了network.automatic-ntlm-auth.trusted-uris设置,则像IE或Firefox )。
msander回答后编辑
所以我现在有了这个:
# Send a simple "message" over a socket - send the number of bytes first,# then the string. Ditto for receive.
def _send_msg(s,m):
s.send(struct.pack("i",len(m)))
s.send(m)
def _get_msg(s):
size_data = s.recv(struct.calcsize("i"))
if not size_data:
return None
cb = struct.unpack("i",size_data)[0]
return s.recv(cb)
def sspi_client():
c = httplib.HTTPConnection("myserver")
c.connect()
# Do the auth dance.
ca = sspi.ClientAuth("NTLM",win32api.GetUserName())
data = None
while 1:
err,out_buf = ca.authorize(data) # error 400 triggered by this line
_send_msg(c.sock,out_buf[0].Buffer)
if err==0:
break
data = _get_msg(c.sock)
print "Auth dance complete - sending a few encryted messages"
# Assume out data is sensitive - encrypt the message.
for data in "Hello from the client".split():
blob,key = ca.encrypt(data)
_send_msg(c.sock,blob)
_send_msg(c.sock,key)
c.sock.close()
print "Client completed."
可以很好地从中删除socket_server.py(请参阅此处)。但是我收到一个错误400-错误的请求。有人还有其他想法吗?
谢谢,
ASP.NET MVC Urls和IIS集成Windows身份验证
如果我将整个站点设置为集成的Windows身份验证,这一切都有效,除了firefox在用户访问站点主页时提示用户输入两次用户名/密码(一次用于Windows身份验证,然后再用于表单身份验证),而IE仅提示表格认证.这很好,我知道这是Firefox的默认行为,但是为了不让用户高兴,我被要求将Windows身份验证要求限制为仅限于网站的/ report / *部分,因此只有在他们转到/ report /%中的任何页面.
在ASP.NET WebForms中这很容易,因为有一个physcial / report文件夹来放置身份验证配置,但在MVC中这个URL是虚拟的,所以我不能这样做.有谁知道这样做的好方法?我试图创建一个“网关”aspx页面,用户在重定向到相应的报告页面之前需要首先完成,虽然Firefox确实在正确的位置提示用户输入他们的Windows凭据,但它似乎没有保留将后续请求的详细信息发送到任何/ report /%页面.有任何想法吗?会非常感激!
解决方法
我最终做的是将我的Web应用程序拆分为两个项目.
第一个项目托管在IIS下的网站根目录中.这是运行表单身份验证.
第二个项目作为同一网站的虚拟目录托管.这是运行Windows身份验证.
唯一的权衡是,您最终可能会得到/ reports / reports /%的URL(或者您为虚拟目录命名的任何内容)
asp.net – iis7中的windows身份验证
如何在IIS7中获得Windows身份验证?
解决方法
完成后单击“确定”,转到IIS管理器,您应该可以在选项中看到Windows身份验证.
asp.net – MVC 3中的Windows身份验证
到目前为止我做了什么:
>在IIS中启用基本身份验证. (我也尝试启用Windows身份验证)
> Web.config< authentication mode =“Windows”>< / authentication>
>我尝试过和没有< identity impersonate =“true”/>
>我已将AuthorizeAttribute放在我的控制器中.
>我也试过了< add key =“autoFormsAuthentication”
值= “假”/>修复MVC3 Beta.
我得到了什么:
我可以打开没有AuthorizeAttribute的页面,我设置了一个断点,这是我在与身份验证相关的不同属性中得到的:
System.Security.Principal.WindowsIdentity.GetCurrent().Name "IIS APPPOOL\\ASP.NET v4.0 DefaultAppPool" Environment.UserDomainName "IIS APPPOOL" Environment.UserName "ASP.NET v4.0 DefaultAppPool" User.Identity.Name ""
当然我无法使用[Authorize]属性打开任何页面.
我唯一想要的是获取正在访问Web应用程序的用户的Windows用户名.我该怎么办?
解决方法
asp.net – Windows 7中Safari 5.x的Windows身份验证问题
Problems with Safari 5.1 in Asp.Net Windows Authentication
Problem using Windows authentication in Safari5.1
Safari 5.1 & Windows authentication broken with modal dialog
Safari 5.x是否存在Windows身份验证问题?如果是这样,如何解决?任何的想法?
解决方法
怎么解决?
在IIS中,转到您网站的身份验证设置.右键单击Windows身份验证,选择提供程序并删除Negotiate,留下NTLM,这使得一切正常.
[参考文献]
> AJAX POST Request Only Works Once in Safari 5
维基百科上的> Negotiate Mechanism文章显示它未在Safari中实现
我们今天的关于使用Python和urllib2的Windows身份验证和python身份验证程序的分享就到这里,谢谢您的阅读,如果想了解更多关于ASP.NET MVC Urls和IIS集成Windows身份验证、asp.net – iis7中的windows身份验证、asp.net – MVC 3中的Windows身份验证、asp.net – Windows 7中Safari 5.x的Windows身份验证问题的相关信息,可以在本站进行搜索。
本文标签: