How read from Active Directory?

  • Thread starter Thread starter Ronald S. Cook
  • Start date Start date
R

Ronald S. Cook

I have no experience with Active Directory and need to programatically read
which user is logged into the domain, the groups they are in, and any other
pertinent information.

Can anyone get me started? I.e. what's the namespace, what does the masic
code look like?

Thanks,
Ron
 
Ronald S. Cook said:
I have no experience with Active Directory and need to programatically read
which user is logged into the domain, the groups they are in, and any other
pertinent information.

Can anyone get me started? I.e. what's the namespace, what does the masic
code look like?

Look for System.DirectoryServices. Code can be a little strange, partly
because of LDAP.
http://www.ondotnet.com/pub/a/dotnet/2003/07/28/activedir.html
I have a good book for it. It might be this one but it doesn't look quite
familiar enough so I'm not sure.
http://www.amazon.com/o/ASIN/1590592697/ref=s9_asin_image_1/002-0170034-7768849
The thing is I remember buying it on Bookpool but I don't see it on Bookpool
right now, so.... ?
 
So if our domain is named "ABC", what would the string look like? Something
like:

Dim objRootDSE As New DirectoryEntry(LDAP://ABC)?

How then can I read (from within .NET Win app) name of user logged in and
groups they are a member of?

On my local machine not on a domain, would I see anything?

Thanks,
Ron
 
Ronald S. Cook said:
So if our domain is named "ABC", what would the string look like?
Something like:

Dim objRootDSE As New DirectoryEntry(LDAP://ABC)?

It is easiest to use "LDAP://RootDSE" since this is the default root
directory. Beyond that LDAP gets confusing in a hurry and I won't comment
further since I can't remember it very well.
 
I have no experience with Active Directory and need to programatically read
which user is logged into the domain,

Active Directory does not offer that information - it's merely a
repository of STATIC information about users, their group memberships
and so forth, but it does NOT contain any runtime information such as
who is currently logged into a server and so forth.

Marc
 
Ronald S. Cook said:
I have no experience with Active Directory and need to programatically read which user is
logged into the domain, the groups they are in, and any other pertinent information.

Can anyone get me started? I.e. what's the namespace, what does the masic code look like?

Thanks,
Ron


As Marc said, you can't get this from the AD. You'll have to use System.Management and get
the current Instances of Win32_LogonSession on the DC. From these instances you will have to
retrieve the associators to find the UserAccount information.
Note that, you will have to connect to and query all DC's in the domain to get all Logins,
note also that this can be extremely time consuming, especially in large domains.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top