RPutilities.ActiveDirectory 1.0.6

dotnet add package RPutilities.ActiveDirectory --version 1.0.6
                    
NuGet\Install-Package RPutilities.ActiveDirectory -Version 1.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RPutilities.ActiveDirectory" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RPutilities.ActiveDirectory" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="RPutilities.ActiveDirectory" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RPutilities.ActiveDirectory --version 1.0.6
                    
#r "nuget: RPutilities.ActiveDirectory, 1.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RPutilities.ActiveDirectory@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RPutilities.ActiveDirectory&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=RPutilities.ActiveDirectory&version=1.0.6
                    
Install as a Cake Tool

A lightweight Active Directory utility library for .NET that supports forest‑wide searches across all domains, flexible LDAP filters, and DTO‑based results with access to all Active Directory attributes.

✅ Async
✅ Forest‑wide search
✅ DTO‑based (no SearchResult leakage)
✅ JSON‑friendly
✅ NuGet‑ready

Search Active Directory across all domains in a forest

✅ SearchAttribute

- UserName
- FullName
- FirstName
- LastName
- All

✅ FilterType

- Contains
- StartWith
- EndsWith
- Is

✅ ObjectClassFilter

- User
- Group
- Computer
- Contact
- OrganizationalUnit
- (and more)

✅Returns DTO objects instead of raw AD objects

✅Access all AD attributes dynamically

✅Easy JSON serialization

✅Windows‑only (Active Directory)

🔍 Search users by LastName

using RPutilities.ActiveDirectory;
using static RPutilities.ActiveDirectory.Options;
var users = await ActiveDirectorySearch.Search("Patel", ObjectClassFilter.User, SearchAttribute.LastName,FilterType.Is,CancellationToken.None);
foreach (var user in users)
{
	richTextBox1.AppendText(
	$"FirstName: {user.Properties["givenName"]}\n" +
	$"LastName: {user.Properties["sn"]}\n"+
	$"Email: {user.Properties["employeeID"]}\n"
	);
}

🔍 Search users across ALL attributes

var users =  await ActiveDirectorySearch.Search("Patel", ObjectClassFilter.User, SearchAttribute.All ,FilterType.Is,CancellationToken.None);

✅ Access Common Properties

foreach (var user in users)
{
	Console.WriteLine($"{user.DisplayName} ({user.SamAccountName})");
}

✅ Access ANY Active Directory Property

foreach (var user in users)
{
	if (user.Properties.TryGetValue("mail", out var email))
	{
		Console.WriteLine($"Email: {email}");
	}	
}

✅ Handle Multi‑Valued Properties (e.g. memberOf)

if (user.Properties.TryGetValue("memberOf", out var groups))
{
	if (groups is object[] values)
	{
		foreach (var group in values)
		{
			Console.WriteLine(group);
		}
	}
}

✅ Serialize to JSON

using System.Text.Json;
string json = JsonSerializer.Serialize(users,new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(json);

list of Properties

user.Properties["objectClass"]
user.Properties["cn"].Value 
user.Properties["displayName"].Value
user.Properties["name"].Value 
user.Properties["distinguishedName"].Value 
user.Properties["userPrincipalName"].Value 
user.Properties["sAMAccountName"].Value 
user.Properties["mail"].Value 
user.Properties["telephoneNumber"].Value 
user.Properties["givenName"].Value 
user.Properties["sn"].Value 
user.Properties["initials"].Value 
user.Properties["l"].Value 
user.Properties["st"].Value 
user.Properties["postalCouser"].Value 
user.Properties["c"].Value 
user.Properties["title"].Value 
user.Properties["userscription"].Value 
user.Properties["company"].Value 
user.Properties["userpartment"].Value 
user.Properties["manager"].Value 
user.Properties["physicaluserliveryOfficeName"].Value 
user.Properties["employeeNumber"].Value 
user.Properties["employeeID"].Value 
getComObjectVal(user.Properties["lastLogon"])
getComObjectVal(user.Properties["pwdLastSet"]
user.Properties["userAccountControl"].Value 
getComObjectVal(user.Properties["accountExpires"]) 
user.Properties["thumbnailPhoto"].Value as byte[]
user.Properties["whenCreated"].Value),
user.Properties["whenChanged"].Value),
user.Properties["memberOf"].Value as object[]??
user.Properties["directReports"].Value as object[]
user.Properties["co"].Value
user.Properties["mobile"].Value 
user.Properties["managedObjects"].Value as object[])
user.Properties["userpartmentNumber"].Value
user.Properties["member"].Value as object[]
user.Properties["managedBy"].Value 

Access above Properties as below example

foreach (var user in users)
{
	richTextBox1.AppendText(
	$"FirstName: {user.Properties["givenName"]}\n" +
	$"LastName: {user.Properties["sn"]}\n"+
	$"Email: {user.Properties["employeeID"]}\n"
	);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 71 2/20/2026

A lightweight Active Directory utility library for .NET that supports forest‑wide searches across all domains, flexible LDAP filters, and DTO‑based results with access to all Active Directory attributes.

     ✅ Async
     ✅ Forest‑wide search
     ✅ DTO‑based (no SearchResult leakage)
     ✅ JSON‑friendly
     ✅ NuGet‑ready

     Search Active Directory across all domains in a forest
     ✅ SearchAttribute
     - UserName
     - FullName
     - FirstName
     - LastName
     - All
     ✅ FilterType
     - Contains
     - StartWith
     - EndsWith
     - Is
     ✅ ObjectClassFilter
     - User
     - Group
     - Computer
     - Contact
     - OrganizationalUnit
     - (and more)

     ✅Returns DTO objects instead of raw AD objects
     ✅Access all AD attributes dynamically
     ✅Easy JSON serialization
     ✅Windows‑only (Active Directory)


     🔍 Search users by username (EndsWith)
               using RPutilities.ActiveDirectory;
               using static RPutilities.ActiveDirectory.Options;

               var users = await ActiveDirectory.SearchAllDomainsAsync(
               ObjectClassFilter.User,
               "patelr",
               SearchAttribute.UserName,
               FilterType.EndsWith,
               CancellationToken.None
               );


     🔍 Search users across ALL attributes
             var users = await ActiveDirectory.SearchAllDomainsAsync(
             ObjectClassFilter.User,
             "patelr",
             SearchAttribute.All,
             FilterType.Contains,
             CancellationToken.None
             );

     ✅ Access Common Properties
           foreach (var user in users)
           {
           Console.WriteLine($"{user.DisplayName} ({user.SamAccountName})");
           }


     ✅ Access ANY Active Directory Property
           foreach (var user in users)
           {
             if (user.Properties.TryGetValue("mail", out var email))
               {
               Console.WriteLine($"Email: {email}");
               }
           }

     ✅ Handle Multi‑Valued Properties (e.g. memberOf)
         if (user.Properties.TryGetValue("memberOf", out var groups))
           {
             if (groups is object[] values)
             {
               foreach (var group in values)
               {
               Console.WriteLine(group);
               }
           }
         }


     ✅ Serialize to JSON
           using System.Text.Json;
           string json = JsonSerializer.Serialize(
           users,
           new JsonSerializerOptions { WriteIndented = true }
           );

         Console.WriteLine(json);