Re: Need help getting the domain SID when given a DC=XXX,DC=YYY,CD=ZZZ



If you want to do this with LDAP (which it looks like you do since you are
using the Domain class), then you could do something like this (you were
almost done!):

Domain curDom = Domain.GetCurrentDomain();
using (DirectoryEntry de = currDom.GetDirectoryEntry())
{
byte[] domSid = (byte[]) de.Properties["objectSid"].Value;
}

If you want a SecurityIdentifier instance, just pass the byte array to the
appropriate constructor.

Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4E060E9E-A1A5-49A4-AC74-B19ACE0A2E56@xxxxxxxxxxxxxxxx
Hi,
I need to get the DomainSID of a given domain. I am using VS2005
C# and .net 2.0. I would most appreciate it if anyone can point me to
some
code
sample.
Domain curDom = Domain.GetCurrentDomain();

--
Thanks.


--
Thanks.


.



Relevant Pages

  • Re: Need help getting the domain SID when given a DC=XXX,DC=YYY,CD
    ... Probably the best thing to do is use the Domain class, ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... this code for getting the domain object? ...
    (microsoft.public.platformsdk.security)
  • Re: Need help getting the domain SID when given a DC=XXX,DC=YYY,CD
    ... SecurityIdentifier si = new SecurityIdentifier ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... Domain curDom = Domain.GetCurrentDomain; ...
    (microsoft.public.platformsdk.security)
  • Re: Need help getting the domain SID when given a DC=XXX,DC=YYY,CD
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... this code for getting the domain object? ... Domain curDom = Domain.GetCurrentDomain; ...
    (microsoft.public.platformsdk.security)
  • Re: find out domain controller programatically
    ... It has a number of methods on the Domain class for locating ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ...
    (microsoft.public.windows.server.active_directory)
  • Re: Web Single Sign On
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... current Windows credentials to the server, ... This common identity is the user's username used to logon to the ...
    (microsoft.public.dotnet.framework.aspnet.security)