• 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

    • Researchers claim Microsoft's quantum breakthrough is flawed by basic Python errors by Karthik Mudaliar Microsoft's aggressive roadmap to deliver a commercial quantum supercomputer by 2029 has now hit a bit of a snag, and it's not because of a complex sub-zero dilution refrigerator, but rather because of a few lines of basic Python code. A new critique published in the scientific journal Nature argues that simple software errors effectively manufactured the breakthrough that Microsoft's foundational research claimed back in 2025 into Majorana-based topological qubits. Topological quantum computing, the path that Microsoft chose for its research, relies on creating and controlling "Majorana zero modes." These are exotic quasiparticles that theoretically offer vastly superior error resistance compared to the highly sensitive superconducting qubits currently being championed by rivals like Google and IBM. However, physically proving you have created these particles requires sifting through massive amounts of complex electrical conductance data to isolate a specific "topological gap." Because of the sheer volume of data, physicists rely heavily on custom software pipelines to process the results. This is where the Python scripts come in. Now, according to the critique, Microsoft’s data processing software contained fundamental programming errors that ultimately skewed the published results. By mishandling data arrays or deploying incorrect logic within the Python script, the software supposedly discarded "noisy" or contradictory data. Which is why it only highlighted the specific electrical measurements that supported the topological-gap claim. The researchers behind the critique argued that this makes the findings invalid, suggesting the heralded "quantum leap" was actually a false positive generated by bad code and not a product of groundbreaking physics. However, Microsoft is pushing back hard against these allegations. The Redmond giant has formally rejected the criticism, saying that it's just a minor anomaly rather than a fatal flaw. According to the company, while there may have been a minor oversight in the data parsing scripts, it does not alter the fundamental reality of their physical experiment. Just weeks ago, Microsoft unveiled the Majorana 2 quantum processor, a milestone so significant that the company boldly accelerated its timeline for a commercial quantum supercomputer from 2035 down to 2029. But the new software allegations reopen an old wound. Microsoft's quantum division faced a remarkably similar crisis when a landmark 2018 paper on Majorana particles was famously retracted in 2021 after independent physicists discovered the data had been inappropriately cropped. That historical baggage makes the current Python-related allegations particularly sensitive. If the foundational math and data processing for the 2025 breakthrough are genuinely flawed, the highly anticipated 2029 commercial timeline could easily be delayed or, worse, cancelled.
    • Because of what they have done to VMware I will never buy anything Broadcom again.
    • AMD releases hotfix for driver install issues on Windows 10 PCs by Taras Buria Earlier this week, AMD released an important graphics driver update. Version 26.6.2 brought AMD FSR 4.1 support to the previous-gen Radeon lineup, the RX 7000 series, giving users better upscaling tech that was previously locked to the newest GPUs. However, the driver turned out to be a little buggy, with users reporting installation issues on systems still running Windows 10. AMD quickly acknowledged the bug and today released a hotfix to resolve the problem. The AMD 26.6.3 Hotfix update is now available for download from the official website. Given that it is a hotfix release, it has only one change in its release notes: AMD announced the update on its official X account and added that a WHQL driver update with the necessary fixes would be released next week. Meanwhile, users can apply the hotfix or roll back to the previous driver using the official AMD Cleanup Utility. You can download AMD Software: Adrenalin Edition 26.6.3 Hotfix Preview Driver from the official website here. It is compatible with all currently supported graphics cards and 64-bit Windows 10 and 11. Full release notes are available on the same page.
    • With Microsoft now listening to its core audience and acting upon received feedback, fans can finally expect a much better version of Windows 11 than what was available five years ago. Here is to five more years, Windows 11! I guess we all need a good laugh now and again...
  • Recent Achievements

    • Dedicated
      Scoobystu earned a badge
      Dedicated
    • First Post
      Tom Schmidt earned a badge
      First Post
    • One Month Later
      D0nn13 earned a badge
      One Month Later
    • Rookie
      +ChiefOfNeo went up a rank
      Rookie
    • One Year In
      Tom Schmidt earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      465
    2. 2
      +Edouard
      177
    3. 3
      PsYcHoKiLLa
      123
    4. 4
      Michael Scrip
      82
    5. 5
      Xenon
      76
  • Tell a friend

    Love Neowin? Tell a friend!