ActiveDirectoryFileManagement 1.0.1

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

// Install ActiveDirectoryFileManagement as a Cake Tool
#tool nuget:?package=ActiveDirectoryFileManagement&version=1.0.1

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. 
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 86 3/5/2024
1.0.3 90 3/5/2024
1.0.2 102 3/5/2024
1.0.1 118 3/3/2024
1.0.0 91 3/3/2024

ActiveDirectoryFileManagement Package.