ActiveDirectoryFileManagement 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ActiveDirectoryFileManagement --version 1.0.0
                    
NuGet\Install-Package ActiveDirectoryFileManagement -Version 1.0.0
                    
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="ActiveDirectoryFileManagement" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ActiveDirectoryFileManagement" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ActiveDirectoryFileManagement" />
                    
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 ActiveDirectoryFileManagement --version 1.0.0
                    
#r "nuget: ActiveDirectoryFileManagement, 1.0.0"
                    
#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 ActiveDirectoryFileManagement@1.0.0
                    
#: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=ActiveDirectoryFileManagement&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ActiveDirectoryFileManagement&version=1.0.0
                    
Install as a Cake Tool

ActiveDirectoryFileManagement

Active Directory Manager

The IActiveDirectoryManager interface defines a contract for managing users within Active Directory. This includes capabilities to retrieve user details, update user attributes, and fetch specific user entries based on their SAM account name.

Methods

GetUser

Retrieves a DirectoryEntry object representing a user in Active Directory based on their SAM account name.

DirectoryEntry? GetUser(string samAccountName);
  • Parameters
    samAccountName: The SAM account name of the user to retrieve.

  • Returns
    A DirectoryEntry object for the specified user if found; otherwise, null.

Example for GetUser

using ActiveDirectoryFileManagement.Interfaces;
using ActiveDirectoryFileManagement.Services;
using ActiveDirectoryFileManagement.Models;
using System;

// Example setup - ensure you have these using directives

class Program
{
    static void Main(string[] args)
    {
        // Initialize Active Directory settings
        var settings = new ActiveDirectorySettings
        {
            Domain = "yourdomain.com",
            Username = "adminusername",
            Password = "adminpassword"
        };

        // Create an instance of your Active Directory manager
        IActiveDirectoryManager adManager = new ActiveDirectoryManager(settings);

        // SAM account name of the user you want to retrieve
        string samAccountName = "jdoe";

        // Use the manager to get the user's DirectoryEntry
        var userDirectoryEntry = adManager.GetUser(samAccountName);

        if (userDirectoryEntry != null)
        {
            // Successfully retrieved the user, you can now work with the DirectoryEntry object
            Console.WriteLine($"User found: {userDirectoryEntry.Properties["name"].Value}");
        }
        else
        {
            Console.WriteLine("User not found.");
        }
    }
}

UpdateUserDetails

Updates specified attributes for a user in Active Directory.

void UpdateUserDetails(string samAccountName, ActiveDirectoryUserDetails userDetails);
  • Parameters
    samAccountName: The SAM account name of the user whose details are to be updated.
    userDetails: An ActiveDirectoryUserDetails object containing the attributes to update.

Example for UpdateUserDetails

class Program
{
    static void Main(string[] args)
    {
        var settings = new ActiveDirectorySettings
        {
            Domain = "yourdomain.com",
            Username = "adminusername",
            Password = "adminpassword"
        };

        IActiveDirectoryManager adManager = new ActiveDirectoryManager(settings);

        string samAccountName = "jdoe";
        var userDetails = new ActiveDirectoryUserDetails()
                            .AddDetail("telephoneNumber", "123-456-7890")
                            .AddDetail("title", "Software Engineer");

        adManager.UpdateUserDetails(samAccountName, userDetails);

        Console.WriteLine("User details updated successfully.");
    }
}

GetUserDetails

Retrieves detailed information about a user from Active Directory.

ActiveDirectoryUserDetails GetUserDetails(string samAccountName);
  • Parameters
    samAccountName: The SAM account name of the user whose details are to be retrieved.
  • Returns
    An ActiveDirectoryUserDetails object containing the user's details.

Example for GetUserDetails

class Program
{
    static void Main(string[] args)
    {
        var settings = new ActiveDirectorySettings
        {
            Domain = "yourdomain.com",
            Username = "adminusername",
            Password = "adminpassword"
        };

        IActiveDirectoryManager adManager = new ActiveDirectoryManager(settings);

        string samAccountName = "jdoe";

        var userDetails = adManager.GetUserDetails(samAccountName);

        if (userDetails != null && userDetails.UserDetails.Count > 0)
        {
            Console.WriteLine("User details retrieved successfully:");
            foreach (var detail in userDetails.UserDetails)
            {
                Console.WriteLine($"{detail.Key}: {detail.Value}");
            }
        }
        else
        {
            Console.WriteLine("User details not found or user has no details.");
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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. 
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.5 312 3/5/2024
1.0.3 249 3/5/2024
1.0.2 237 3/5/2024
1.0.1 241 3/3/2024
1.0.0 228 3/3/2024

ActiveDirectoryFileManagement Package.