private bool IsAuthenticated(String server, String path, String username, String pwd) // String port,
{
String domainAndUsername = username;
DirectoryEntry entry;
//if (port != String.Empty)
//{
entry = new DirectoryEntry("LDAP://" + server + "/" + path, "ITSC\\" + domainAndUsername, pwd);
//}
//else
//{
// entry = new DirectoryEntry("LDAP://" + server + ":" + port + "/" + path, domainAndUsername, pwd);
//}
try
{
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (result == null)
{
return false;
}
//_path = result.Path;
//_filterAttribute = (String)result.Properties["cn"][0];
return true;
}
catch
{
return false;
}
}
{
String domainAndUsername = username;
DirectoryEntry entry;
//if (port != String.Empty)
//{
entry = new DirectoryEntry("LDAP://" + server + "/" + path, "ITSC\\" + domainAndUsername, pwd);
//}
//else
//{
// entry = new DirectoryEntry("LDAP://" + server + ":" + port + "/" + path, domainAndUsername, pwd);
//}
try
{
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (result == null)
{
return false;
}
//_path = result.Path;
//_filterAttribute = (String)result.Properties["cn"][0];
return true;
}
catch
{
return false;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货