WMIConn.UserName 属性

定义

如果不使用 Windows 身份验证,则获取或设置连接的用户名。

public:
 property System::String ^ UserName { System::String ^ get(); void set(System::String ^ value); };
public string UserName { get; set; }
member this.UserName : string with get, set
Public Property UserName As String

属性值

一个字符串,其中包含连接的用户名。

示例

下面的代码示例将 WMI 连接添加到包,并设置ServerName以及UserNamePassword属性。 需要修改代码示例,以便为应用程序的属性提供适当的值。

ConnectionManager WmiConn = pkg.Connections.Add("WMI");  
DtsProperty prop = WmiConn.Properties["ServerName"];  
prop.SetValue(WmiConn, @"\\localhost");  
WmiConn.Properties["Username"].SetValue(WmiConn, @"");  
WmiConn.Properties["Password"].SetValue(WmiConn, @"");  
Dim WmiConn As ConnectionManager =  pkg.Connections.Add("WMI")   
Dim prop As DtsProperty =  WmiConn.Properties("ServerName")   
prop.SetValue(WmiConn, "\\localhost")  
WmiConn.Properties("Username").SetValue(WmiConn, @"")  
WmiConn.Properties("Password").SetValue(WmiConn, @"")  

注解

如果不使用 Windows 身份验证,则必须为连接提供用户名和密码。

适用于