CaptainQwerty.ActiveDirectoryEasyAPI 1.0.0

dotnet add package CaptainQwerty.ActiveDirectoryEasyAPI --version 1.0.0                
NuGet\Install-Package CaptainQwerty.ActiveDirectoryEasyAPI -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="CaptainQwerty.ActiveDirectoryEasyAPI" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CaptainQwerty.ActiveDirectoryEasyAPI --version 1.0.0                
#r "nuget: CaptainQwerty.ActiveDirectoryEasyAPI, 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.
// Install CaptainQwerty.ActiveDirectoryEasyAPI as a Cake Addin
#addin nuget:?package=CaptainQwerty.ActiveDirectoryEasyAPI&version=1.0.0

// Install CaptainQwerty.ActiveDirectoryEasyAPI as a Cake Tool
#tool nuget:?package=CaptainQwerty.ActiveDirectoryEasyAPI&version=1.0.0                

ActiveDirectoryTools

This library gives quick to use methods for Active Directory covering tools to manage accounts, groups and audit tasks. The API can only perform these tasks if the script / program executing the API is ran from an account with permissions to perform the task being used.

README is still no where near done... Currently it's just notes...

Features

Audit Tasks Setup and Usage

Creating an instance of the AuditTtasks class.

var auditTasks = new AuditTasks();

DoesOrganisationalUnitExist(string organisationalUnit)

Using this method and supplying the distinguised name of the organisational unit will return a booleon for if it exists or not.

var ouExists = auditTasks.DoesOrganisationalUnitExist("OU=Test Ou,DC=gen2training,DC=co,DC=uk");
Console.WriteLine($"OU Exists: {ouExists}")

// If the Ou exists it will return true, if not it will return false.

GetAllLockedOutAccounts()

Returns a UserAccount object for each locked account.

var lockedOutAccounts = auditTasks.GetAllLockedOutAccounts();

foreach (var lockedAccount in lockedOutAccounts)
{
    Console.WriteLine(lockedAccount.Username);
}

User Account Tasks

Creating an instance of the UserAccountTasks class.

var userAccountTasks = new UserAccountTasks();

GetUserAccountDetails(string username)

For the supplied username, if the account is found a UserAccount model is returned with populated values based on the information from the account.

var user = userAccountTasks.GetUserAccountDetails("antony.bragg");

Console.WriteLine($"{user.FirstName} {user.LastName}'s locked out status is: {user.LockedOut}");

// Result: "Antony Bragg's locked out statis is: False"

UnlockAccount(string username)

Supplied account will be unlocked.

userAccountTasks.UnlockAccount("antony.bragg");

SetUsersPassword(string username, string password) or SetUsersPassword(string username, string password, bool expireNow)

Supplying a username and a new password will reset the users password. If no bool is supplied as a third property the account password will not be immedietly expired, if true is supplied the account password will be reset and expired forcing the user to set a new password at log on.

userAccountTasks.SetUsersPassword("antony.bragg", "DemoPassword123"); // Resets password
userAccountTasks.SetUsersPassword("antony.bragg", "DemoPassword123", true); // Resets password and expires password

MoveToOrganisationalUnit(string username, string newOrganisationalUnit)

The supplied user account will be moved to the given organisational unit if it exists. The organisational unit's distinguised name is required.

userAccountTasks.MoveToOrganisationalUnit("antony.bragg", "OU=Disabled Accounts,DC=gen2training,DC=co,DC=uk");

GetLastLogOn(string username)

Not recommended for use yet.

GetThumbnailPhoto(string username)

Returns the users thumbnail photo in a byte format. In the next version of the software this will be exportable in a range of formats.

var photo = userAccountTasks.GetThumbnailPhoto("antony.bragg");

Group Account Tasks

Creating an instance of the GroupAccountTasks class.

var groupAccountTasks = new GroupAccountTasks();

RemoveUserFromGroup(string username, string groupName)

groupAccountTasks.RemoveUserFromGroup("antony.bragg", "Domain Admins");

AddUsertoGroup(string username, string groupName)

groupAccountTasks.AddUsertoGroup("antony.bragg", "Domain Admins");

GetGroupMembers(string groupName)

var membersOfGroup = groupAccountTasks.GetGroupMembers("Domain Admins");

foreach (var user in membersOfGroup)
{
    Console.WriteLine($"{user.FirstName} {user.LastName}");
}

GetGroupDetails(string groupName)

var group = groupAccountTasks.GetGroupDetails("Domain Admins");
            
Console.WriteLine(group.Name);
Console.WriteLine(group.Description);
foreach (var user in group.GroupMembers)
{
                Console.WriteLine($"{user.Username}");
}

Prerequisites

.NET 3.5 or above

Installing

Installation from NuGet - Package on Nuget

PM> Install-Package CaptainQwerty.ActiveDirectoryEasyAPI -Version 1.0.0

Authors

Acknowledgements

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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.0 971 11/3/2018

Initial release.