共用方式為


類別SMS_Identification中的 GetCurrentUser 方法

GetCurrentUser Configuration Manager 中的 Windows Management Instrumentation (WMI) 類別方法會取得 SMS 提供者用於驗證的網域\用戶名稱。

下列語法是從受控物件格式 (MOF) 程式代碼中簡化,並定義方法。

語法

SInt32 GetCurrentUser(
     String UserName
);

參數

UserName 資料類型: String

限定符:[out]

SMS 提供者所使用的網域\用戶名稱。 此名稱可能與應用程式提供的網域\用戶名稱不同,視所使用的網域信任模型而定。

傳回值

數據 SInt32 類型,為 0 表示成功或非零表示失敗。

如需處理傳回錯誤的相關信息,請參閱關於 Configuration Manager 錯誤

範例程序代碼

下列範例示範如何呼叫這個方法來取得目前的使用者。

Dim Identification As SWbemObject
Dim UserName As String

Set Identification = GetObject("winmgmts:\root\sms\site_<sitecode>:SMS_Identification")
Identification.GetCurrentUser UserName

MsgBox "UserName = " & UserName

需求

運行時間需求

如需詳細資訊,請參閱 Configuration Manager 伺服器運行時間需求。

開發需求

如需詳細資訊,請參閱 Configuration Manager 伺服器開發需求。

另請參閱

SMS_Identification伺服器 WMI 類別