How to check if a given user is a member of the built-in Administrators group?

后端 未结 4 1665
刺人心
刺人心 2021-01-15 03:28

I need to check programmatically (in .NET) whether a given user (domain account) is a member of the built-in Administrators group on a current computer (the one where the ap

4条回答
  •  孤街浪徒
    2021-01-15 03:54

    I don't know about .Net, but in win32, the easy way is to call IsUserAnAdmin(). If you need more control, you can open the process token and check with CheckTokenMembership for each group you need to check

    Edit: See pinvoke.net for .NET sample code (Thanks chopeen)

提交回复
热议问题