判断用户名、密码是否可以连接到windows域

来源:互联网 发布:淘宝黑搜技术 编辑:程序博客网 时间:2024/06/03 20:47
    private string IsConnected(string domainName, string userName, string userPwd)    {                DirectoryEntry domain = new DirectoryEntry();        try        {            domain.Path = string.Format("LDAP://{0}", domainName);            domain.Username = userName;            domain.Password = userPwd;            domain.AuthenticationType = AuthenticationTypes.Secure;            domain.RefreshCache();            return "通过";        }        catch (Exception ex)        {                        return ex.Message;        }    }

0 0