从System.DirectoryServices切换到DirectoryServices.Protocols时,身份验证类型可能会有所不同。在System.DirectoryServices中,身份验证类型通常是通过设置DirectoryEntry对象的AuthenticationType属性来实现的。而在DirectoryServices.Protocols中,身份验证类型通常是通过设置LdapConnection对象的Credential属性来实现的。
在DirectoryServices.Protocols中,可以使用以下方法来设置身份验证类型:
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("localhost"));
connection.Credential = null;
connection.AuthType = AuthType.Anonymous;
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("localhost"));
NetworkCredential credential = new NetworkCredential("username", "password");
connection.Credential = credential;
connection.AuthType = AuthType.Basic;
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("localhost", 636), new NetworkCredential("username", "password"), AuthType.Basic);
connection.SessionOptions.SecureSocketLayer = true;
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("localhost", 636), new NetworkCredential("username", "password"), AuthType.Basic);
connection.SessionOptions.SecureSocketLayer = true;
connection.SessionOptions.EnableLockingAndPaging = true;
总之,在使用DirectoryServices.Protocols时,可以根据需要选择不同的身份验证类型,以满足不同的安全需求。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云