사용자 이름과 도메인을 기반으로 사용자의 전체 이름을 검색하는 기능이 있습니다. 이 함수는 가장 된 사용자 아래의 ASP.NET 스레드에서 실행됩니다. 원격 AD 지점에서 Directory searcher를 사용할 때 속성 대신 SID 번호가 표시된다고 (다른 상자에서 발생하는지 확인할 수 없음)Active Directory 검색에서 지연 바인딩을 어떻게 극복 할 수 있습니까?
public string GetUserFullName(string userName, string domainName)
{
DirectoryEntry rootEntry = new DirectoryEntry("GC://dc=company,dc=net");
string filter = string.Format("(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(userPrincipalName={0}@{1}.company.net))", userName, domainName);
DirectorySearcher searcher = new DirectorySearcher(rootEntry, filter, new string[] { "displayName" });
rootEntry.AuthenticationType = AuthenticationTypes.Secure;
searcher.PageSize = 1000;
searcher.ServerTimeLimit = new TimeSpan(0, 10, 0);
searcher.ReferralChasing = ReferralChasingOption.All;
searcher.Asynchronous = false;
SearchResult result = searcher.FindOne();
if (result != null)
{
return (string) result.Properties["displayName"][0];
}
else
{
throw new Exception("Active Directory could not resolve your user name");
}
}
NET 2.0입니다. 이것을 지적 주셔서 감사합니다 !!! 애드리안 –