Mono Class Library: System.Security.Principal Namespace

System.Security.Principal.WindowsIdentity Class

This class represent an operating system identity (user). [Edit]

See Also: WindowsIdentity Members

[System.Runtime.InteropServices.ComVisible(true)]
public class WindowsIdentity : IDisposable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable, IIdentity

Remarks

The WindowsIdentity class can also be used on POSIX compliant operating system.

C# Example
// are we running on UNIX ?
switch ((int)Environment.OSVersion.Platform) {
	case 4:		// new value added by MS in 2.0 framework
	case 128:		// old value used by Mono for 1.x framework
		// then if UID is 0 you're root!
		if (WindowsIdentity.GetCurrent ().Token == IntPtr.Zero) {
        	       Console.WriteLine ("Cool you're root!");
		}
		break;
	default:
		Console.WriteLine ("You're not running on a Unix-like operating system");
		break;
	}
}
  
[Edit]

Requirements

Namespace: System.Security.Principal
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0