当前位置:网站首页>ConnectionOptions. Username attribute definition
ConnectionOptions. Username attribute definition
2022-06-21 14:55:00 【allway2】
Namespace :
Assembly :
System.Management.dll
Gets or sets the user name that will be used for the connection operation .
C# Copy
public string Username { get; set; }Property value
return String value , This value is used to connect to WMI User name used when .
Example
The following example connects to a remote computer , And displays information about the operating system on the remote computer . ConnectionOptions Create a connection to the remote computer using the required connection options .
C# Copy
using System;
using System.Management;
public class RemoteConnect
{
public static void Main()
{
// Build an options object for the remote connection
// if you plan to connect to the remote
// computer with a different user name
// and password than the one you are currently using.
// This example uses the default values.
ConnectionOptions options =
new ConnectionOptions();
options.Username = "UserName";
// Make a connection to a remote computer.
// Replace the "FullComputerName" section of the
// string "\\\\FullComputerName\\root\\cimv2" with
// the full computer name or IP address of the
// remote computer.
ManagementScope scope =
new ManagementScope(
"\\\\FullComputerName\\root\\cimv2", options);
scope.Connect();
//Query system for Operating System information
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope,query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach ( ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Computer Name : {0}",
m["csname"]);
Console.WriteLine("Windows Directory : {0}",
m["WindowsDirectory"]);
Console.WriteLine("Operating System: {0}",
m["Caption"]);
Console.WriteLine("Version: {0}", m["Version"]);
Console.WriteLine("Manufacturer : {0}",
m["Manufacturer"]);
}
}
}
annotation
If the user name comes from a domain other than the current domain , The string may contain the domain name and user name , Separate with backslash : character string "username" = "EnterDomainHere \ \EnterUsernameHere". strUser Parameter cannot be an empty string .
Property value
null If the connection will use the currently logged in user , Then for ; otherwise , A string representing the user name . The default value is null.
.NET Framework Security
Full trust in the direct caller . This member cannot be used by partially trusted code . For more information , see also Using libraries from partially trusted code .
Apply to
| product | edition |
|---|---|
| .NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
| .NET Platform Extensions | 2.1, 2.2, 3.0, 3.1, 5.0, 6.0 |
边栏推荐
- 2022 Fujian latest fire protection facility operator simulation test question bank and answers
- Browser evaluation: a free, simple and magical super browser - xiangtian browser
- Is it safe to open a securities account by downloading the app of qiniu school? Is there a risk?
- Windows系统下C语言连接MySQL
- ES6 test questions
- Numpy: basic package for high performance scientific computing & data analysis
- 通过编译内核的方式增加系统调用
- Continuous attack animation
- Nmap scan port tool
- What is a naked cat
猜你喜欢

T32 custom menu bar

Decipher Bishengyuan: is it tea that consumers buy, or is it IQ tax?

Summary of the most basic methods of numpy

Numpy: basic package for high performance scientific computing & data analysis

ARP interaction process
![The whole process of Netease cloud music API installation and deployment [details of local running projects and remote deployment]](/img/3b/678fdf93cf6cc39caaec8e753af169.jpg)
The whole process of Netease cloud music API installation and deployment [details of local running projects and remote deployment]

Summary of web development technology knowledge

How is the network connected

Win10 install tensorflow

!!** The test is valid * *:vscode "the terminal will be reused by the task, press any key to close" /vscode the terminal runs NPM to pop up the select program dialog box / try a new cross platform Pow
随机推荐
Summary of common libraries in machine learning
Compile time annotation automatically generates dataholder
P24 de noise
Link storage structure of simulated design disk file
Common data processing of machine learning
Word thesis typesetting tutorial
Mqtt keepalive and reconnect
Finding minimum spanning tree by using union search set
Small case of anti shake function
Make word2vec for Bert model
Use ant for running program with command line arguments
Talk about MySQL's locking rule "hard hitting MySQL series 15"
T32 custom menu bar
Chapter 3 - data link layer
Clickhouse cluster installation has too many dry goods
Gensim error attributeerror: type object 'word2vec' has no attribute 'load_ word2vec_ format‘
JS written test question: asynchronous
Is the switch network layer
Fundamentals of C language 13: file input / output
Reasonably set the number of threads 【 rpm 】