Exemplo n.º 1
0
        protected override void InternalProcessRecord()
        {
            int num = ServicePrincipalName.RegisterServiceClass("SmtpSvc");

            if (num == 0)
            {
                base.WriteVerbose(Strings.SpnRegistrationSucceeded);
            }
            else
            {
                this.WriteWarning(Strings.SpnRegistrationFailed(num));
            }
            List <string> recipients = new List <string>(this.Recipients.Count);

            foreach (ProxyAddress proxyAddress in this.Recipients)
            {
                recipients.Add(proxyAddress.AddressString);
            }
            using (ServerPickerManager serverPickerManager = new ServerPickerManager("Test-Message cmdlet", ServerRole.HubTransport, ExTraceGlobals.BridgeheadPickerTracer))
            {
                PickerServerList pickerServerList = serverPickerManager.GetPickerServerList();
                try
                {
                    PickerServer pickerServer = null;
                    bool         flag         = false;
                    while (!flag)
                    {
                        PickerServer hub = pickerServerList.PickNextUsingRoundRobinPreferringLocal();
                        if (hub == null)
                        {
                            this.WriteWarning(Strings.NoHubsAvailable);
                            break;
                        }
                        if (pickerServer == null)
                        {
                            pickerServer = hub;
                        }
                        else if (hub == pickerServer)
                        {
                            this.WriteWarning(Strings.NoHubsAvailable);
                            break;
                        }
                        base.WriteVerbose(Strings.TryingToSubmitTestmessage(hub.MachineName));
                        int[] source = new int[]
                        {
                            25,
                            2525
                        };
                        if (source.Any((int port) => this.TrySendMessage(recipients, hub, port)))
                        {
                            flag = true;
                        }
                    }
                }
                finally
                {
                    pickerServerList.Release();
                }
            }
        }
Exemplo n.º 2
0
 public static void ServicePrincipalName(String ip, String domain, String username, String password)
 {
     if (String.IsNullOrEmpty(username))
     {
         using (ServicePrincipalName spn = new ServicePrincipalName(ip))
         {
             spn.QueryUsers();
             spn.Print();
         }
     }
     else
     {
         using (ServicePrincipalName spn = new ServicePrincipalName(ip, username, password))
         {
             spn.QueryUsers();
             spn.Print();
         }
     }
 }