从Windows身份验证应用程序中的当前用户获取网络凭据 [英] Obtain Network Credentials from Current User in Windows Authentication Application
问题描述
我想知道是否有可能获取当前的用户对象并获取其凭据,以便将它们传递给正在用于连接到AX .NET Business Connector的NetworkCredential
对象.因为,目前我必须指定它以实例化NetworkCredential
对象时设置的特定用户身份连接:
I was wondering whether it was possible to obtain the current user object and get their credentials so that I can pass them along to a NetworkCredential
object which I am using to connect to my AX .NET Business Connector. As, at the moment I'm having to specify it connect as a specific user which I set when I instantiate a NetworkCredential
object:
private NetworkCredential nc = new NetworkCredential("myUser", "myPassword", "myDomain");
我希望做类似的事情:private NetworkCredential nc = (NetworkCredential)HttpContext.User;
,但是显然那行不通...
I was hoping to do something like: private NetworkCredential nc = (NetworkCredential)HttpContext.User;
but obviously that won't work...
通过这种方式,例如,跟踪哪个用户创建了销售订单会更容易,因为目前所有事情都是由我指定的用户创建的.
That way, it's easier to keep track of which user has created a sales order for example, as at the moment everything gets created by the user I have specified..
推荐答案
CredentialCache.DefaultNetworkCredentials
?
DefaultNetworkCredentials
返回的凭据表示运行应用程序的当前安全上下文的身份验证凭据.对于客户端应用程序,这些通常是运行该应用程序的用户的Windows凭据(用户名,密码和域).
The credentials returned by
DefaultNetworkCredentials
represents the authentication credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application.
这篇关于从Windows身份验证应用程序中的当前用户获取网络凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!