public GenericIdentity(string name);
public GenericIdentity(string name, string type);
現在我們不過多地講述使用GenericIdentity類的細節問題,在后面我們將會看到在一個實際的程序當中是如何使用GenericIdentity對象的。
WindowsIdentity類
作為實現了IIdentity接口的派生類,WindowsIdentity類主要用于表示登陸Windows成功的用戶。下面我們依次來看看WindowsIdentity類的構造函數,屬性和方法。
在構造函數中會用到IntPtr類型的參數,我們先來看看這種數據類型,IntPtr類型通常用來表示與平臺相關的數據類型,比如一個內存指針或者是一個句柄。在我們使用的情況下,IntPtr參數通常用來代表一個Win32句柄,而這個句柄指向的是一個32位的用戶的帳號標記(account token)。這個標記一般是通過調用非托管的Win32 API獲得的。
public WindowsIdentity(IntPtr userToken);
public WindowsIdentity(IntPtr userToken, string authType);
public WindowsIdentity(IntPtr userToken, string authType, WindowsAccountType acctType);
public WindowsIdentity(IntPtr userToken, string authType, WindowsAccountType acctType, bool isAuthenticated);
每一個構造函數都帶有相同的IntPtr參數,后面跟著一些帶有其他信息的參數:驗證類型,Windows帳號類型以及驗證狀態。要注意WindowsAccountType參數必須要使用下列枚舉值之一:Anonymous,Guest,Normal,System。
文章來源于領測軟件測試網 http://www.kjueaiud.com/