결과

2013-07-18 3 views
0

나는 현재 Active Directory 사용자를 가져 오지 다음 저장소 방법이 있습니다 -결과

public List<DomainContext> GetADUsers(string term=null) 
{ 
    List<DomainContext> results = new List<DomainContext>(); 
    using (var context = new PrincipalContext(ContextType.Domain, "WIN-SPDEV")) 
    using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) 
    { 
     var searchResults = searcher.FindAll(); 



     foreach (Principal p in searchResults) 
     { 
      if (term == null || p.SamAccountName.ToString().ToUpper().StartsWith(term.ToUpper())) 
      { 
      DomainContext dc = new DomainContext(); 
      dc.DisplayName = p.DisplayName; 
      dc.UserPrincipalName = p.UserPrincipalName; 
      dc.Name = p.Name; 
      dc.SamAccountName = p.SamAccountName ; 
      dc.DistinguishedName =  p.DistinguishedName; 

      results.Add(dc); 

     }} 
    } 
    return results; 
} 

는 그래서 AD의 사용자로, 난의 결과를 캐시 할 필요가 너무 자주 변경하지 않습니다 약 2 시간 동안이 방법. 그래서이 메소드를 호출하면 Active Directory를 호출해서는 안됩니까? 액션 메소드에 정의 된 [OutputCache]과 동일한 로직을 실제로 구현하려고합니다. 감사합니다.

+2

가'[OutputCache를]'왜 당신의 Active Directory 사용자를 반환하는 작업을 장식하는 데 사용할 언급하면서 : 나는 최신 문서까지 더 발견

? – haim770

+0

활성 디렉토리를 리턴하는 지정된 조치 메소드가 없습니다. Repository Model 클래스 내의 메소드입니다. –

답변