What equivalent of AuthenticationTypes.Secure in PrincipalCo

本文关键字:in PrincipalCo Secure AuthenticationTypes equivalent of What | 更新日期: 2023-09-27 18:20:48

如标题所示,我正在尝试将DirectoryEntry参数转换为PrincipalContext,但在DirectionEntry中没有看到等效于AuthenticationTypes.Secure的ContextOption。

AuthenticationTypes.Secure:http://msdn.microsoft.com/en-us/library/system.directoryservices.authenticationtypes.aspx

请求安全身份验证。当设置此标志时,WinNT提供程序使用NTLM对客户端进行身份验证。Active Directory域服务使用Kerberos(可能还有NTLM)对客户端进行身份验证。当用户名和密码为空引用时(Nothing inVisual Basic),ADSI使用的安全上下文绑定到对象调用线程,它是用户的安全上下文运行应用程序的帐户或客户端用户的帐户调用线程正在模拟的帐户。

上下文选项:http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.contextoptions.aspx

我看不到类似的东西。。。。

What equivalent of AuthenticationTypes.Secure in PrincipalCo

根据我的经验,ContextOptions.Negotiate相当于AuthenticationTypes.Secure。请参阅MSDN上对这两个值的描述。

上下文选项。协商-客户端通过使用Kerberos或NTLM进行身份验证。当没有提供用户名和密码时,帐户管理API通过使用调用线程的安全上下文绑定到对象,该安全上下文要么是运行应用程序的用户帐户的安全上下文,要么是调用线程表示的客户端用户帐户的安全上下文。

AuthenticationTypes.Secure-请求安全身份验证。设置此标志后,WinNT提供程序将使用NTLM对客户端进行身份验证。Active Directory域服务使用Kerberos(可能还有NTLM)对客户端进行身份验证。

您可以使用以下代码对此进行测试:

PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
                                     "test.int",
                                     "CN=Users,DC=test,DC=int",
                                     ContextOptions.Negotiate,
                                     "administrator",
                                     "SecurePassword");
UserPrincipal usr = new UserPrincipal(ctx);
usr.Name = "Jim Daly";
usr.SamAccountName = "Jim.Daly";
usr.UserPrincipalName = "Jim.Daly@test.int";
usr.Description = "This is the user account for Jim Daly";
usr.EmailAddress = "jimdaly@test.int";
usr.SetPassword("VerySecurePwd");
usr.Save();
  
// Get the underlying directory entry.
DirectoryEntry de = (DirectoryEntry)usr.GetUnderlyingObject();
// Print the authentication type 
Console.Out.WriteLine(de.AuthenticationType);

我认为其他选项如下:

ContextOptions.Sealing -> AuthenticationTypes.Sealing
ContextOptions.SecureSocketLayer -> AuthenticationTypes.Encryption
ContextOptions.ServerBind -> AuthenticationTypes.ServerBind
ContextOptions.Signing -> AuthenticationTypes.Signing
ContextOptions.SimpleBind -> AuthenticationTypes.None