RE: Determining my PC's SID ?
From: jzhu (anonymous_at_discussions.microsoft.com)
Date: 04/30/04
- Next message: Ayende Rahien: "Unable to change RSA keysize?"
- Previous message: Andi: "Certificate Revocation List CRT"
- In reply to: Richard Purchas: "Determining my PC's SID ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 30 Apr 2004 07:51:05 -0700
Assuming that the computer is in W2K or later domain, the simplest way is to use Win32 LookupAccountName through interop. You need to append a "$" to the computer name for the lookup.
If you don't want to deal with interop, take a look at
http://www.datamarvel.com
It has most Win32 API, including LookupAccountName, exported. The following code will work:
NET_SID sid = null;
string domain = "";
NET_SID_NAME_USE use = NET_SID_NAME_USE.SidTypeUnknown;
NSid nsid;
WinBase.LookupAccountName(null, "myDomain\\myComputer$", ref sid, ref domain, ref use);
nsid = new NSid(sid); // For dumping SID in string.
Console.WriteLine("Computer sid {0}, use {1}", nsid.StringSid, use);
- Next message: Ayende Rahien: "Unable to change RSA keysize?"
- Previous message: Andi: "Certificate Revocation List CRT"
- In reply to: Richard Purchas: "Determining my PC's SID ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]