473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

User Listing from AD

I need to get a listing of users from Active Directory. Getting the list is
no problem using the DirectorySearcher class. My problem is getting the full
legacy-style domain name of the user (in the form of domain\username). The
"sAMAccountName" property only gives me the username portion. What property
gives with the domain? Or do I need to be looking at a different AD object
altogether?

Thanks,
Jason
Jul 21 '05 #1
3 1811
>I need to get a listing of users from Active Directory. Getting the list is
no problem using the DirectorySearcher class. My problem is getting the full
legacy-style domain name of the user (in the form of domain\username). The
"sAMAccountName" property only gives me the username portion. What property
gives with the domain? Or do I need to be looking at a different AD object
altogether?


You can't get that from a user object - you'd have to go inspect the
"domainDNS" object that this user (or those users) are contained
under.

E.g. you'd have to walk up the AD object tree (by looking at the
DirectoryEntry.Parent property repeatedly) and go find the object of
class "domainDNS" - it will contain an attribute called "name" which
is the NetBIOS style name of the domain.

MArc

================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Jul 21 '05 #2
Thanks Marc for the info.

Looks like I need to look at the instanceType field that specifies that
object type? (In this case the value 5 indicates domainDNS) Or should I be
looking at something else?

- Jason

"Marc Scheuner [MVP ADSI]" <m.********@inova.SPAMBEGONE.ch> wrote in message
news:6l********************************@4ax.com...
I need to get a listing of users from Active Directory. Getting the list
is
no problem using the DirectorySearcher class. My problem is getting the
full
legacy-style domain name of the user (in the form of domain\username). The
"sAMAccountName" property only gives me the username portion. What
property
gives with the domain? Or do I need to be looking at a different AD object
altogether?


You can't get that from a user object - you'd have to go inspect the
"domainDNS" object that this user (or those users) are contained
under.

E.g. you'd have to walk up the AD object tree (by looking at the
DirectoryEntry.Parent property repeatedly) and go find the object of
class "domainDNS" - it will contain an attribute called "name" which
is the NetBIOS style name of the domain.

MArc

================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch

Jul 21 '05 #3
>Looks like I need to look at the instanceType field that specifies that
object type? (In this case the value 5 indicates domainDNS) Or should I be
looking at something else?


Yes - why not look at the "DirectoryEntry.SchemaClassName" property??

It will contain the schema class name, e.g. "user" for users,
"domainDNS" for domains, "group" for groups and so on.

Marc

================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Neal | last post by:
Hi, I'm fairly new to developing PHP / MySQL databases. I've just created a job posting board that works OK, but I want this feature: user creates their username/password to enter a listing. Once...
6
by: Brad | last post by:
I have an sql query that has specific criteria (like state='PA' or state = 'NJ'...) and would like to be able to have the user specify the criteria dynamically either through the web or from...
3
by: David Jacques | last post by:
I am trying to get a list of all files of a certain extension type on disk to do some processing in a loop. The code needs to be portable to UNIX, so I need to use plain c functionality. Does...
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
2
by: moondaddy | last post by:
I have a user control that's used to display the products listing in the main part of a page. This control is populated with a listing of products from the database based on a category name passed...
3
by: Jason | last post by:
I need to get a listing of users from Active Directory. Getting the list is no problem using the DirectorySearcher class. My problem is getting the full legacy-style domain name of the user (in the...
2
by: s.chelliah | last post by:
We have an input field which allows the user to enter a string of (up to 62) ASCII printable characters. We have a need to allow the user to be able to specify any sequence of characters he/she...
1
by: vhg119 | last post by:
Can someone please link me to some resource listing all the user attributes names? I'm writing some C# code using the System.DirectoryServices assembly. This particular function is suppose to...
3
by: =?Utf-8?B?ZG1idXNv?= | last post by:
I would like a listing of all users in the current domain (or on my computer). I'm running Windows XP Home Edition and I've set up four user, one for each member of my family. 'My.User.Name'...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.