问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/9486348/how-can-i-get-the-user-name-who-invoked-the-method-of-com-server