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 _
)
[C#]
public WindowsPrincipal(
   WindowsIdentity ntIdentity
);
[C++]
public: WindowsPrincipal(
   WindowsIdentity* ntIdentity
);
[JScript]
public function WindowsPrincipal(
   ntIdentity : WindowsIdentity
);

Parameters

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

Exceptions

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

Example

[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)        


[C#] 

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

[C++] 

 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.

Requirements

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

Show: