2014-12-15 3 views
0

클라이언트 : win XP embedded; 서버 : 승리 서버 2008다시 시작한 후 C# 코드가 ldap에 연결할 수 없습니다.

코드 :

private DirectorySearcher getDirectorySearcher() 
    { 
     Runtime.Log.Info("Root Path Format: " + _rootPath); 
     _directoryEntry = new DirectoryEntry(_rootPath, _username, _password); 
     try 
     { 
      _directoryEntry.RefreshCache(); 

      return new DirectorySearcher(_directoryEntry) 
      { 
       PageSize = 1000 
      }; 
     } 
     catch (Exception ex) 
     { 
      _directoryEntry.Close(); 
      _directoryEntry.Dispose(); 
      throw; 
     } 
    } 

이 코드는 정상적인 상황에서 잘 작동합니다.

시작되지 않은 LDAP 서버에 연결 한 후 오류가 발생하지만 LDAP 서버를 다시 시작하면 서버에도 연결할 수 없습니다. 클라이언트에서 exe를 다시 시작하면이 문제가 해결됩니다.

오류 정보는 다음과 같습니다

Exception authenticating user 'Administrator' 

    System.Runtime.InteropServices.COMException (0x8007203A): The server is not operational. 

     at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) 
     at System.DirectoryServices.DirectoryEntry.Bind() 
     at System.DirectoryServices.DirectoryEntry.RefreshCache() 
     at ThreeVR.EnterpriseServer.Ldap.LdapContext.getDirectorySearcher() 

나는 새로 고치거나하여 DirectoryEntry 및 DirectorySearcher 개체를 처리하기 위해 모든 방법을 시도했지만 작동하지.

아무에게도 조언을 줄 수 있습니까? 어떤 아이디어?

답변

0

DNS 캐시를 비울 수 있습니까?

using System.Runtime.InteropServices; 

... 

[DllImport("dnsapi.dll",EntryPoint="DnsFlushResolverCache")] 
private static extern UInt32 DnsFlushResolverCache(); 

... 

public static void FlushResolverCache() 
{ 
    UInt32 result = DnsFlushResolverCache(); 
} 
관련 문제