如何获取调用COM服务器方法的用户名? [英] How can I get the user name who invoked the method of COM server?

查看:179
本文介绍了如何获取调用COM服务器方法的用户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C ++编写的COM服务器在网络中的某台计算机上运行。客户端可以从其他计算机执行远程调用。我可以从方法本身确定调用COM方法的用户的名称吗?

I have a COM server written in C++ running on some computer in a network. Clients may perform remote calls to it from the other computers. Can I determine the name of the user which make the call to the COM-methods from the methods itself?

推荐答案

通过调用 CoImpersonateClient()。假冒您假冒的人,您可以致电 GetUserNameEx()以获取用户名。

You can accomplish this by calling CoImpersonateClient() from within a COM method. One you're impersonating, you can then call GetUserNameEx() to fetch the user name.

这篇关于如何获取调用COM服务器方法的用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆