SID lookup .NET 2.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way in VB.NET 2.0 to lookup a SID when given a username? If
so could you provide an example. Thanks...
 
If you find a way, please post it, I'm interested in this also -- primarily
it would help me quickly determine path to my installed apps that used the
MSI installs. As a worky solution I just load the entire subkey entries and
cycle thru them to find what I'm looking for -- pretty quick since there are
rarely more than 100 entries (certainly faster than trying to locate a file
on all local and/or removeable drives) for our typical client PCs.
 
Thus wrote Nick,
Is there an easy way in VB.NET 2.0 to lookup a SID when given a
username? If so could you provide an example. Thanks...

Well, there's a super easy way in the *.NET Framework* 2.0 ;-)

This sample uses C#, but the important stuff is easy to pick up:

string userName = @"foo\joe";
NTAccount account = new NTAccount(userName);
SecurityIdentifier sid = (SecurityIdentifier) account.Translate(typeof(SecurityIdentifier));

Both NTAccount and SecurityIdentifier belong to the System.Security.Principal
namespace.

Cheers,
 
Back
Top