Active Directory, enumerating user's groups, COM exception

后端 未结 3 703
盖世英雄少女心
盖世英雄少女心 2021-01-15 18:00

while enumerating current user\'s groups through AD .NET API I sometimes get

COMException: Unknown error (0x80005000)

Here\'s my code :

3条回答
  •  [愿得一人]
    2021-01-15 18:16

    Try using

    var context = new PrincipalContext(ContextType.Domain, "yourcompany.com", "DC=yourcompany,DC=com", ContextOptions.Negotiate);
    

    With the ContextOption set to Negotioate the client is authenticated by using either Kerberos or NTLM so even if the user name and password are not provided the account management API binds to the object by using the security context of the calling thread.

提交回复
热议问题