This documentation is archived and is not being maintained.

WindowsPrincipal Constructor

Initializes a new instance of the WindowsPrincipal class from a WindowsIdentity object.

[Visual Basic]
Public Sub New( _
   ByVal ntIdentity As WindowsIdentity _
public WindowsPrincipal(
   WindowsIdentity ntIdentity
public: WindowsPrincipal(
   WindowsIdentity* ntIdentity
public function WindowsPrincipal(
   ntIdentity : WindowsIdentity


The WindowsIdentity object from which to construct the new instance of WindowsPrincipal.


Exception Type Condition
ArgumentNullException The ntIdentity parameter is a null reference (Nothing in Visual Basic).


[Visual Basic, C#, C++] The following example creates a new WindowsPrincipal object from the current WindowsIdentity object.

[Visual Basic] 

 Dim wi As WindowsIdentity = WindowsIdentity.GetCurrent()
 Dim wp As New WindowsPrincipal(wi)        


 WindowsIdentity wi = WindowsIdentity.GetCurrent();
 WindowsPrincipal wp = new WindowsPrincipal(wi);


 WindowsIdentity* wi = WindowsIdentity::GetCurrent();
 WindowsPrincipal* wp = new WindowsPrincipal(wi);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

WindowsPrincipal Class | WindowsPrincipal Members | System.Security.Principal Namespace