Delphi 2009中如何获取当前登录用户,包括域?
我需要获取当前登录的用户名?当我从在 Windows 身份验证模式下工作的 ASP.NET 调用代码时,我需要它正常工作。即我不想在这种情况下获得 ASPNET 用户,而是模拟用户。这与我之前的问题相关。我尝试的一切都会返回ASPNET。
I need to get the current logged on username? I need this to work properly when I call the code from ASP.NET which is working in Windows Authentication mode. i.e. I do not want to get the ASPNET user in that circumstance, but the impersonated user. This is related to my earlier question. Everything I try returns ASPNET.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的另一个问题中,您写道您将 ASP.NET 配置为使用 Windows 身份验证进行模拟:
ASP.NET 应用程序是否显示正确的凭据(用户和域)?
您是否使用正确的身份上下文调用Delphi函数,例如
更新:
如果从Web表单页面的代码隐藏中调用COM对象,您可以尝试将Web表单页面的ASPCOMPAT属性设置为true。
请参阅:
In your other question you wrote that you configured ASP.NET to use Windows authentication with impersonation:
Does the ASP.NET application show the correct credentials (user and domain)?
Are you invoking the Delphi function using the correct Identity context, like
Update:
If the COM abject is called from the code behind for a web form page, you can try to set ASPCOMPAT property of the web form page to true.
See:
也许您的 IADsWinNTSystemInfo 方法(来自链接的上一个问题)返回当前进程的帐户信息,但 ASP.NET 是在线程级别模拟?
试试这个:
示例用法:
希望这会有所帮助。
Perhaps your
IADsWinNTSystemInfo
approach (from the linked previous question) returns current process' account information, but ASP.NET is impersonating on a thread level?Try this:
Example usage:
Hope this helps.
这是我的 LoadProfile工具,在Delphi 2010中运行良好:
This is a part of the code of my LoadProfile tool, it works well in Delphi 2010: