I would like to check in VBA, in which roles 开发者_开发知识库is user logged in windows.
Can anyone help?
I believe there is no built-in way of doing this in VBA.
Probably the easiest way of doing this would be expose a COM Automation interface from a DLL that retrieves this information and exposes it to your vba program. Another alternate is Win32 API call but I'm not sure which function. Do some digging on Win32 API and I'm sure you'll get a suitable function (P/Invoke repository may be of much help)
WindowsIdentity
is the class I think that will give you a good starting point.
WindowsIdentity
lives in System.Security.Principal
in .net framework that you can use to expose the information via COM interface (I'm going out on a limb here and assuming you can program in .net -- if not, you will have to find a dll that already exposes this information)
If you are experienced with programming in .net and just need help on how to implement this information, drop a shout back here and I'll share some of my code that I use for same purpose.
精彩评论