/// <exception cref="SharpCifs.Smb.SmbException"></exception> /// <exception cref="UnknownHostException"></exception> public static NtlmChallenge GetChallengeForDomain() { if (Domain == null) { throw new SmbException("A domain was not specified"); } lock (Domain) { long now = Runtime.CurrentTimeMillis(); int retry = 1; do { if (DcListExpiration < now) { NbtAddress[] list = NbtAddress.GetAllByName(Domain, 0x1C, null, null); DcListExpiration = now + CachePolicy * 1000L; if (list != null && list.Length > 0) { DcList = list; } else { DcListExpiration = now + 1000 * 60 * 15; if (SmbTransport.LogStatic.Level >= 2) { SmbTransport.LogStatic.WriteLine("Failed to retrieve DC list from WINS"); } } } int max = Math.Min(DcList.Length, LookupRespLimit); for (int j = 0; j < max; j++) { int i = DcListCounter++ % max; if (DcList[i] != null) { try { return(Interrogate(DcList[i])); } catch (SmbException se) { if (SmbTransport.LogStatic.Level >= 2) { SmbTransport.LogStatic.WriteLine("Failed validate DC: " + DcList[i]); if (SmbTransport.LogStatic.Level > 2) { Runtime.PrintStackTrace(se, SmbTransport.LogStatic); } } } DcList[i] = null; } } DcListExpiration = 0; }while (retry-- > 0); DcListExpiration = now + 1000 * 60 * 15; } throw new UnknownHostException( "Failed to negotiate with a suitable domain controller for " + Domain); }
public override void Run() { try { //Ans = new [] { NbtAddress.GetByName(Host, Type, Scope, Svr) }; Ans = NbtAddress.GetAllByName(Host, Type, Scope, Svr); } catch (UnknownHostException uhe) { this.Uhe = uhe; } catch (Exception ex) { Uhe = new UnknownHostException(ex.Message); } finally { lock (Sem) { Sem.Count--; Runtime.Notify(Sem); } } }