• 0

.NET & Windows Active Directory


Question

Recommended Posts

  • 0

Sorry guys,

I'm just a little confused. Do i need to use LDAP (which i don't really know what after reading about it in Wiki) ? Or ADSI ?

Please correct me if i am wrong. ADSI is Active Directory Service Interface. Basically what it does is it forms a bridge for programmers like us to communicate with the Active Directory.. Am i right or I am totally screwed ? Haha ?

Don

  • 0

Lightweight Directory Access Protocol (LDAP): It is a protocol for accessing information directories such as organizations, individuals, phone numbers, and addresses. It is based on the X.500 directory protocols, but it is simpler, and unlike X.500, it supports TCP/IP for Internet usage. The standards are specified in RFC 1777.

  • 0

Quick sample:

This code will return a list of all users in active directory.

Make sure you add this to your class:

using System.DirectoryServices;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

DirectoryEntry rootEntry = new DirectoryEntry();
rootEntry.Path = "LDAP://example.com/DC=example,DC=com";
rootEntry.Username = "{admin account}";
rootEntry.Password = "{admin password}";
rootEntry.AuthenticationType = AuthenticationTypes.Secure;

DirectorySearcher dirSearcher = new DirectorySearcher(rootEntry);
dirSearcher.Filter = "(&(objectCategory=Person)(objectClass=user))";
dirSearcher.PropertiesToLoad.Add("sAMAccountName");

SearchResultCollection resultsColl = dirSearcher.FindAll();
foreach (SearchResult result in resultsColl)
{
	if (result.Properties.Contains("sAMAccountName"))
	{
		string account = (string)result.Properties["sAMAccountName"][0];		
		sb.AppendLine(account);
	}
}

// your user account list, saved in a string
string userAccounts = sb.ToString();

You would replace example.com with your domain and replace the {admin account} and {admin password} with the user credentials of a user that has access to read active directory (ie: a domain admin).

  • 0
Just a quick question,

if (result.Properties.Contains("sAMAccountName"))

Why are you checking if the results contains sAMAccountName?

Sorry if thats a silly question

If there is a null value in a result, then you will get an error if you try to assign it to a variable. It is just a safety precaution.

  • 0

Oh, i guess i got the whole idea wrong.

To have a Windows Active Directory, I need a Windows Server to be running right ? And the IP that is assigned to the Windows Server will be the domain name ?

And the windows Active directory gives the admin 1 control point to control all the computers that are connected to the windows server

Is my concept right now ?

  • 0

http://en.wikipedia.org/wiki/Active_Directory

Sort of.

One (or several mirrored) domain server controls user access to all computers connected to the domain.

We have two domain controllers and about 250 computers under active directory.

http://www.microsoft.com/downloads/details...;DisplayLang=en

This includes the active directory tools.

  • 0
Is everything in the AD retrievable ? Or some are not ? Example like the password ?

I believe the user's password is stored as a hash, so really its only used for validation, no retrieval.

It might also depend on how you connect to the directory, anonymously, or via authentication?

  • 0
But for my case, even if it is stored as a hash, I am still interested in retrieving it so will I still be able to get the information ?

Given that I am logged in via authentication as the highest priviledged user.

I don't think you can retrieve it, however I know that you can alter it :)

  • 0

Hmn... alright. Thanks guys!

I'm giving a shot using JAVA instead of .NET reason being i am more familiar with JAVA.

The site that Sartoris gave me was very USEFUL (TYPO SORRY!). They use an external lib call jldap. Anyone uses that can share their knowledge ?

Edited by donchen
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I agree, especially if it is cloud sourced, like this one is.. but I wouldn't say no to a local AI assistant similar to the Zettlab one which would be really helpful with my large Photos library, but also to perform tasks like installing Docker apps rather than me having to do it via Docker Compose, but I don't think we're quite there yet. Synology Photos is somewhat AI, you can ask it to search for certain people (if you have tagged them and it will attempt to match similar photos to the person) and if you put a search term in for "cars" for example, it will show you all photos with a car.
    • I doubt that Google will keep the same price... it may go up from that list published.
    • Sennheiser's audiophile grade HD 600 hits lowest ever price on Amazon Prime Day 2026 by Sayan Sen If you are in the market for high-quality audiophile-grade over-ear headphones then Sennheiser's HD 600 are a great choice for sure, especially today on Prime Day 2026 as the product has hit its lowest ever price (purchase link under the specs table down below). The Sennheiser HD 600 has long been regarded as a reference headphone for listeners seeking a detailed and natural listening experience. It is an open-back design that is built around the idea of acoustic transparency which is essentially said to allow sound waves to move freely for a more spacious and accurate presentation by reducing turbulence and the type of distortion that can result from it. At the heart of the product is Sennheiser’s proprietary driver system featuring a 42 mm driver paired with a lightweight diaphragm and aluminum voice coils. The company says this design helps deliver fast response times and better articulate sound across the audible frequency range. Comfort and durability are also key aspects of the HD 600 as the headphones feature soft velour ear pads designed for extended listening sessions. The HD 600 comes with a detachable 3-meter cable, a 6.3 mm stereo connector, and a 3.5 mm adapter for compatibility with a wide range of audio equipment. The technical specs of the Sennheiser HD 600 are given in the table below: Specification Value Transducer Principle Dynamic, Open-Back Ear Coupling Circumaural (Over-Ear) Frequency Response 12 Hz – 40,500 Hz Sound Pressure Level (SPL) 97 dB (1 V) Impedance 300 Ω Total Harmonic Distortion (THD) < 0.1% (1 kHz, 1 V) Cable Length 3 m (9.8 ft) Connector 3.5 mm Stereo Jack Plug Included Adapter 6.3 mm (1/4") Stereo Jack Adapter Weight 260 g Magnetic Field Strength 1.8 mT Driver Size 42 mm Dynamic Driver Diaphragm Size 38 mm Get it at the link below: Sennheiser HD 600: $237.00 (Sold by Electronics Expo, Shipped by Amazon US) (Was: $449.95) Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases
    • So the card is targeted at headphone users - so the review should be from someone that uses this - maybe I can review a card next time.
  • Recent Achievements

    • One Month Later
      timbobit earned a badge
      One Month Later
    • One Month Later
      nates earned a badge
      One Month Later
    • Week One Done
      Almohandis earned a badge
      Week One Done
    • Rookie
      dorf went up a rank
      Rookie
    • First Post
      mike_rumble earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      476
    2. 2
      +Edouard
      170
    3. 3
      PsYcHoKiLLa
      104
    4. 4
      Michael Scrip
      88
    5. 5
      Steven P.
      70
  • Tell a friend

    Love Neowin? Tell a friend!