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);
}