62,046
社区成员
发帖
与我相关
我的任务
分享
using System.DirectoryServices;
/// <summary>
/// APAC为域名
/// </summary>
/// <param name="usrId"></param>
/// <param name="pwd"></param>
/// <returns></returns>
public static bool IsAPACUser(string usrId, string pwd)
{
try
{
using (DirectoryEntry de = new DirectoryEntry())
{
de.Path = "LDAP://APAC";
de.Username = "APAC\\" + usrId;
de.Password = pwd;
DirectorySearcher search = new DirectorySearcher(de);
search.Filter = "(SAMAccountName=" + usrId + ")";
search.PropertiesToLoad.Add("CN");
SearchResult r = search.FindOne();
if (r == null)
{
de.Close();
return false;
}
else
{
de.Close();
return true;
}
}
}
catch (Exception ex)
{
return false;
}
}
string LoginUser = Request.ServerVariables["LOGON_USER"];
string[] LoginUserArr = LoginUser.Split('\\');
//取用户ID
string UserID = LoginUserArr[1];
//取域名
string DomainID = LoginUserArr[0];
string LoginUser = Request.ServerVariables["LOGON_USER"];
string[] LoginUserArr = LoginUser.Split('\\');
//取用户ID
string UserID = LoginUserArr[1];
//取域名
string DomainID = LoginUserArr[0];