如何启用用户在active directory下访问vpn
本文关键字:directory active 访问 vpn 用户 何启用 启用 | 更新日期: 2023-09-27 18:15:25
如何使用c#编程语言使用户能够访问活动目录中的VPN。
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无关。
代码看起来像是在验证用户是否存在,但是它很奇怪