Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用户能够访问active directory中的vpn_C# - Fatal编程技术网

C# 如何使用户能够访问active directory中的vpn

C# 如何使用户能够访问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=

如何使用c语言让用户访问active directory中的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无关


代码似乎是在验证用户是否存在,但这很奇怪。

如果我将用户添加到组中,他是否可以使用vpn连接?