Find current users active directory group C++

假装没事ソ 提交于 2019-12-04 20:34:40

In your particular case I think you can do without any LDAP calls. Here's a suggestion:

  • use GetCurrentProcessId and OpenProcess to get a handle to the current process
  • call OpenProcessToken on that handle to open the access token associated with the current process
  • call GetTokenInformation on that access token, with a token information class of TokenGroups
  • the resulting TOKEN_GROUPS structure contains a list with the SIDs and attributes of all the groups in the access token
  • call LookupAccountSid on the SID of each group in the list to obtain its name

MSDN should provide more detailed information about the calls mentioned above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!