在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System.DirectoryServices; using System.DirectoryServices.AccountManagement; using (DirectoryEntry adsEntry = new DirectoryEntry("LDAP://test.com", userName, password, AuthenticationTypes.Secure)) { using (DirectorySearcher adsSearcher = new DirectorySearcher(adsEntry)) { adsSearcher.Filter = "(sAMAccountName=" + userName + ")"; try { SearchResult adsSearchResult = adsSearcher.FindOne(); } catch (Exception ex) { // 用户名或密码错误 string strError = ex.Message; } finally { adsEntry.Close(); } } }
|
请发表评论