使用 Excel vsto 进行 Windows 身份验证
我在 Excel 中面临集成 Windows 身份验证的问题。我有两台服务器 IIS 5 托管旧代码(宏),IIS 6 托管新代码。在客户端上,为了避免每个服务器出现多个凭据对话框,我希望用户仅在 IIS 5 上进行身份验证。第一步是使用 HttpWebRequest 和 com CredUIPromptForCredentials 在 IIS 5 上对用户进行身份验证。但即使此步骤在 IIS 5 上对用户进行身份验证,当尝试访问 IIS 5 时,遗留代码(宏)会再次显示凭据质询对话框。
这是我创建 CredUIPromptForCredentials
CREDUI_FLAGS flags = CREDUI_FLAGS.ALWAYS_SHOW_UI | CREDUI_FLAGS.GENERIC_CREDENTIALS;
CredUIReturnCodes returnCode = CredUIPromptForCredentials(ref credUI, Application.ProductName, IntPtr.Zero, 0, userID, 100, userPassword, 100, ref save, flags);
请求对象的方式
var authCredCache = new CredentialCache();
authCredCache.Add(new Uri(authServer), "Negotiate",
new NetworkCredential(user, pwd, domain));
httpWebRequest.Credentials = authCredCache;
I am facing problem with integrated windows authentication in excel. I have two server IIS 5 hosting legacy code(macro), and IIS 6 hosting new code. On client to avoid multiply credential dialog for each server I want user to be authenticated only on IIS 5. As a first step am authenticating user on IIS 5 using HttpWebRequest along with com CredUIPromptForCredentials. But even if this step authenticates the user on IIS 5 the legacy code(macro) when try to access IIS 5 shows up credential challenge dialog again.
here is how I am creating CredUIPromptForCredentials
CREDUI_FLAGS flags = CREDUI_FLAGS.ALWAYS_SHOW_UI | CREDUI_FLAGS.GENERIC_CREDENTIALS;
CredUIReturnCodes returnCode = CredUIPromptForCredentials(ref credUI, Application.ProductName, IntPtr.Zero, 0, userID, 100, userPassword, 100, ref save, flags);
request object
var authCredCache = new CredentialCache();
authCredCache.Add(new Uri(authServer), "Negotiate",
new NetworkCredential(user, pwd, domain));
httpWebRequest.Credentials = authCredCache;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论