• 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

    • Apple and Tesla trade secrets reportedly exposed following a Tata Electronics cyberattack by Hamid Ganji Image via Depositphotos.com Tata Electronics has confirmed that it detected a cybersecurity incident in some of its systems. The Indian company is a manufacturing partner of both Apple and Tesla, and the incident may have exposed some trade secrets belonging to the two American companies. The World Leaks ransomware group is said to be behind the attack, and it has reportedly posted up to 200,000 files on the dark web, including component designs and specification documents related to Apple and Tesla products. Tata Electronics told Reuters that its response protocols were deployed immediately and that the “incident has had no impact on our operations across businesses, which remain unaffected.” The ransomware group reportedly sent a ransom demand to Tata Electronics, while Apple has launched an investigation into the incident. World Leaks claims it stole more than 200,000 files totaling over 630GB from Tata Electronics. Some database files on the ransomware group’s website are titled "com.apple.factorydata," which could refer to Apple’s iPhone production operations in India. Moreover, some documents reportedly contain material specifications and quality inspection standards for iPhone circuit board components. However, Apple is not the only affected company. A folder found in the World Leaks database is titled "NV36 Chargeport Controller - North America," which may refer to Tesla Model Y components. Additionally, other files in the database reportedly contain drawings related to Tesla’s Project Highland, the internal codename for the EV maker’s updated Model 3 sedan. To support the authenticity of the stolen files, World Leaks has published documents containing footers that read: "This document contains proprietary and confidential information of Apple Inc." and "information contained herein is deemed confidential, proprietary, and a trade secret of Tesla Inc." Cybersecurity researcher Rajshekhar Rajaharia told Reuters that the database also contains emails, event logs spanning several years, and passport copies of employees, including foreign nationals. Both Tesla and Apple have declined to comment on the scale of the incident.
    • Last time I used Pascal was in college about 40 yrs ago, programmed an inventory database for my exam.
    • If they don't sell enough of the 1st gen then there won't be a 2nd gen
    • Epic fail, should've added an eSata port on the back, also if the memory/NVME are soldered then they're hardly gonna sell any, first thing most people do with their Steamdeck is, or used to be, replacing the NVME with a 2TB one. At that price they should, possibly for the first time, offer an installments option, say 24 months, they may sell a lot if they do. I'm sure they would have no shortage of credit companies willing to partner.
  • Recent Achievements

    • 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
    • Dedicated
      tuben earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      487
    2. 2
      +Edouard
      204
    3. 3
      PsYcHoKiLLa
      94
    4. 4
      Michael Scrip
      91
    5. 5
      neufuse
      71
  • Tell a friend

    Love Neowin? Tell a friend!