C# 如何使用户能够访问active directory中的vpn
如何使用c语言让用户访问active directory中的vpnC# 如何使用户能够访问active directory中的vpn,c#,C#,如何使用c语言让用户访问active directory中的vpn string username = "Abc user"; string _path; string _filterAttribute; try { DirectoryEntry myLdapconnection=new DirectoryEntry("domain"); myLdapconnection.Path = "LDAP://OU=
string username = "Abc user";
string _path;
string _filterAttribute;
try
{
DirectoryEntry myLdapconnection=new DirectoryEntry("domain");
myLdapconnection.Path = "LDAP://OU=,OU=,DC=,DC=,DC=";
myLdapconnection.AuthenticationType = AuthenticationTypes.Secure;
object obj = myLdapconnection.NativeObject;
DirectorySearcher search = new DirectorySearcher(myLdapconnection);
search.Filter = "(cn=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
s="True";
if (null == result)
{
s= "false";
}
// Update the new path to the user in the directory.
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
}
catch (Exception ex)
{
s="Error authenticating user. " + ex.Message;
}
从上面的代码来看,下面语句的功能是什么
object obj = myLdapconnection.NativeObject;
这是启用vpn的语句吗
若我将用户添加到组中,那个么他是否可以使用vpn连接 因为上述代码中未使用obj;它没有任何功能,与VPN无关
代码似乎是在验证用户是否存在,但这很奇怪。如果我将用户添加到组中,他是否可以使用vpn连接?