Example #1
0
 private void AddEndpoint(ref ResultItemMap resultMap, ComputerInfo server, DetectResult result)
 {
     AddResultItem(ref resultMap, "ComputerName: ", server.ComputerName, result);
     AddResultItem(ref resultMap, "FQDN: ", server.FQDN, result);
     if (string.IsNullOrEmpty(server.IPv4))
     {
         AddResultItem(ref resultMap, "IP: ", server.IPv6, result);
     }
     else
     {
         AddResultItem(ref resultMap, "IP: ", server.IPv4, result);
     }
     AddResultItem(ref resultMap, "NetBIOS: ", server.NetBIOS, result);
     // AddResultItem(ref resultMap,"ComputerPwd: ",server.Password,result);
     //  AddResultItem(ref resultMap,"Port: ",server.Port,result);
     AddResultItem(ref resultMap, "ServiceSalt: ", server.ServiceSalt, result);
     AddResultItem(ref resultMap, "DefaultServiceName: ", server.DefaultServiceName, result);
     AddResultItem(ref resultMap, "IsWindows: ", server.IsWindows.ToString(), result);
 }
        private bool DetectClient(DomainInfo domain, ComputerInfo client)
        {
            logWriter.AddLog(string.Format("===== Detect Client in Domain {0} =====", domain.Name), LogLevel.Normal);

            string ip = client.IPv4 != null ? client.IPv4 : client.IPv6;

            try
            {
                string computerName = Dns.GetHostEntry(ip).HostName;
                computerName = computerName.Split('.')[0];
                client.FQDN = ServerHelper.GetAccountAttribute(computerName, "Computers", "dNSHostName", domain.Name, domain.Admin, domain.AdminPassword);
            }
            catch
            {
                logWriter.AddLog("Failed", LogLevel.Normal, false, LogStyle.StepFailed);
                logWriter.AddLineToLog(LogLevel.Advanced);
                return false;
            }

            if (client.FQDN == null)
            {
                logWriter.AddLog("Failed", LogLevel.Normal, false, LogStyle.StepFailed);
                logWriter.AddLineToLog(LogLevel.Advanced);
                return false;
            }

            string[] tempArray = client.FQDN.Split('.');
            client.ComputerName = tempArray[0];

            try
            {
                client.NetBIOS = ServerHelper.GetAccountAttribute(client.ComputerName, "Computers", "sAMAccountName", domain.Name, domain.Admin, domain.AdminPassword);//DC01$: NetBIOS name
                client.DefaultServiceName = "host/" + client.FQDN.ToLower();
                client.ServiceSalt = domain.Name.ToUpper() + "host" + client.FQDN.ToLower();
                client.IsWindows = true; //client is always windows.
            }
            catch
            {
                logWriter.AddLog("Failed", LogLevel.Normal, false, LogStyle.StepFailed);
                logWriter.AddLineToLog(LogLevel.Advanced);
                return false;
            }

            logWriter.AddLog("Success", LogLevel.Normal, false, LogStyle.StepPassed);
            logWriter.AddLineToLog(LogLevel.Advanced);
            return true;
        }