Exemplo n.º 1
0
		private EnumerationClient CreateClient (NativeDestinationOptions options, string queryDialect)
		{
			string serverName = string.IsNullOrEmpty (options.ServerName) ? "localhost" : options.ServerName;
			serverName = "localhost";
			int port = options.DestinationPort <= 0 ? 5985 : options.DestinationPort;
			string prefix = string.IsNullOrEmpty (options.UrlPrefix) ? "http://" : options.UrlPrefix;
			var binding = new WSManBinding();
			ChannelFactory<IWSEnumerationContract> cf = new ChannelFactory<IWSEnumerationContract>(binding);

			cf.Credentials.UserName.UserName = options.UserName;
			cf.Credentials.UserName.Password = options.Password;

			EnumerationClient client = new EnumerationClient(true, new Uri(string.Format("{0}{1}:{2}/wsman", prefix, serverName, port)), cf);
			client.BindFilterDialect(queryDialect, typeof(CimEnumerationFilter));
			return client;
		}
Exemplo n.º 2
0
        private EnumerationClient CreateClient(NativeDestinationOptions options, string queryDialect)
        {
            string serverName = string.IsNullOrEmpty(options.ServerName) ? "localhost" : options.ServerName;

            serverName = "localhost";
            int    port    = options.DestinationPort <= 0 ? 5985 : options.DestinationPort;
            string prefix  = string.IsNullOrEmpty(options.UrlPrefix) ? "http://" : options.UrlPrefix;
            var    binding = new WSManBinding();
            ChannelFactory <IWSEnumerationContract> cf = new ChannelFactory <IWSEnumerationContract>(binding);

            cf.Credentials.UserName.UserName = options.UserName;
            cf.Credentials.UserName.Password = options.Password;

            EnumerationClient client = new EnumerationClient(true, new Uri(string.Format("{0}{1}:{2}/wsman", prefix, serverName, port)), cf);

            client.BindFilterDialect(queryDialect, typeof(CimEnumerationFilter));
            return(client);
        }