• 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

    • "Claude, is our CEO a compete and utter fool by wasting money on AI in this already worthless Teams chat?"
    • Endless Wars  Endless Shrimp!!! 🦐    
    • How can it beat a Steam machine without a serious GPU? The two CU iGPU only provides about 5fps in gaming. That's not going to make any gamer happy.
    • Anthropic introduces Claude Tag, a new AI teammate for Slack by Fiza Ali Anthropic has announced Claude Tag, a new feature that lets teams work with Claude directly inside Slack. The idea is simple: once Claude is added to a Slack workspace and given access to selected channels, users can tag @Claude in conversations and assign tasks. Claude can then work through those requests using connected tools and data sources before posting its results back into a Slack thread. What makes Claude Tag different from a typical chatbot is that it's designed to operate as a shared assistant for an entire team rather than a single user. Everyone in a channel interacts with the same Claude instance. This allows the team members to see ongoing work and continue tasks started by others. Furthermore, Anthropic says the AI can build context over time by following conversations in channels where it has permission to operate. This means users don't have to repeatedly provide the same background information for every request. The system is also designed for asynchronous work. Instead of waiting for responses in a chat window, users can assign a task to Claude and return later once the work is complete. Anthropic says Claude can break larger requests into multiple steps and use connected tools to complete them. Moreover, the system can also schedule follow-up tasks and continue working on projects over extended periods. Another feature allows Claude to keep the users updated and follow up on unresolved tasks when its optional "ambient" mode is enabled. The company says the tool is already being used internally for software development, data analysis, support workflows, and debugging. According to Anthropic, around 65% of its product team's code is now generated through its internal version of Claude Tag. For organisations concerned about security, administrators can control which channels, tools, and data sources Claude can access. Separate Claude instances can also be configured for different departments, helping keep information isolated between teams. Administrators can also monitor activity logs, review completed tasks, and set spending limits at both the organisation and channel level. Claude Tag is now available in beta for Claude Enterprise and Claude Team customers and runs on Claude Opus 4.8 that was announced this May. The feature will also replace Anthropic's existing Claude in Slack application, with current users able to migrate within a 30-day migration window. Lastly, eligible customers will receive introductory credits to help teams evaluate the new experience.
  • Recent Achievements

    • Rookie
      DaviKar went up a rank
      Rookie
    • Dedicated
      HidekoYamamoto94 earned a badge
      Dedicated
    • 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
  • Popular Contributors

    1. 1
      +primortal
      462
    2. 2
      +Edouard
      161
    3. 3
      PsYcHoKiLLa
      110
    4. 4
      Michael Scrip
      83
    5. 5
      Steven P.
      69
  • Tell a friend

    Love Neowin? Tell a friend!