Hi, I'm using VS2003 C#, .net 2.0 running on Windows Server 2000.
I have a User's SID in SDDL format and also a DIRECTORYENTRY object
representing this user object. How can I retrieve the name of the domain
that this user object belongs to?
Probably the easiest way is create a SecurityIdentifier object and convert
it to an NTAccount with the Translate method. You could also get the prefix
of the SID and query AD to find the domainDNS object that has that SID.
Joe K.

Signature
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
> Hi, I'm using VS2003 C#, .net 2.0 running on Windows Server 2000.
>
> I have a User's SID in SDDL format and also a DIRECTORYENTRY object
> representing this user object. How can I retrieve the name of the domain
> that this user object belongs to?
Pucca - 20 Dec 2006 03:25 GMT
Hi Joe,
This is what I got so far. I need to get the domain name in a string. How
can I do that from here? thank you.
//sid = S-1-5-21-1993962763-879983540-725345543-500
SecurityIdentifier sdSID = new SecurityIdentifier(sid);
string domainSid = sdSID.AccountDomainSid.Value.ToString();
SecurityIdentifier domain = new SecurityIdentifier(domainSid);

Signature
Thanks.
> Probably the easiest way is create a SecurityIdentifier object and convert
> it to an NTAccount with the Translate method. You could also get the prefix
[quoted text clipped - 7 lines]
> > representing this user object. How can I retrieve the name of the domain
> > that this user object belongs to?
Joe Kaplan - 20 Dec 2006 05:02 GMT
NTAccount account = domain.Translate(typeof(NTAccount));
Alternately, you could just translate the user SID and parse out the domain
name.
Joe K.

Signature
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
> Hi Joe,
>
[quoted text clipped - 21 lines]
>> > domain
>> > that this user object belongs to?