Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/Bitai.LDAPHelper.Demo/Bitai.LDAPHelper.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<Copyright>© 2026 BITAI. All rights reserved.</Copyright>
<PackageId>Bitai.Bitai.LDAPHelper.Demo</PackageId>
<PackageIcon>hierarchy_32.png</PackageIcon>
<Version>10.0.0</Version>
<AssemblyVersion>10.0.0</AssemblyVersion>
<FileVersion>10.0.0</FileVersion>
<Version>10.0.1</Version>
<AssemblyVersion>10.0.1</AssemblyVersion>
<FileVersion>10.0.1</FileVersion>
<PackageReleaseNotes>.NET 10 ready</PackageReleaseNotes>
<PackageTags>ldap-ad-identity-auth-openid-oauth-security</PackageTags>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions demo/Bitai.LDAPHelper.Demo/Program.DemoMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ public static async Task Demo_AccountManager_SetPassword(DemoContext context, st
Log.Information($"Enter new password for {distinguishedName}");

var password = requestAccountPassword(distinguishedName);
var credential = new LDAPDistinguishedNameCredential(distinguishedName, password);

var accountManager = new AccountManager(context.GetClientConfiguration(), context.ConnectionFactory);

Log.Information("Setting account password...");
var result = await accountManager.SetUserAccountPasswordForMsAD(credential, context.RequestLabel);
var result = await accountManager.SetMsADUserAccountPassword(EntryAttribute.distinguishedName, distinguishedName, password, context.RequestLabel);

if (result.IsSuccessfulOperation)
{
Expand All @@ -172,7 +172,7 @@ public static async Task Demo_AccountManager_DisableUserAccount(DemoContext cont
var accountManager = new AccountManager(context.GetClientConfiguration(), context.ConnectionFactory);

Log.Information("Disabling user account {dn}", distinguishedName);
var result = await accountManager.DisableUserAccountForMsAD(distinguishedName, context.RequestLabel);
var result = await accountManager.DisableMsADUserAccount(EntryAttribute.distinguishedName, distinguishedName, context.RequestLabel);

if (result.IsSuccessfulOperation)
{
Expand All @@ -194,7 +194,7 @@ public static async Task Demo_AccountManager_RemoveUserAccount(DemoContext conte
var accountManager = new AccountManager(context.GetClientConfiguration(), context.ConnectionFactory);

Log.Information("Removing user account {dn}", distinguishedName);
var result = await accountManager.RemoveUserAccountForMsAD(distinguishedName, context.RequestLabel);
var result = await accountManager.RemoveMsADUserAccount(EntryAttribute.distinguishedName, distinguishedName, context.RequestLabel);

if (result.IsSuccessfulOperation)
{
Expand Down
239 changes: 156 additions & 83 deletions src/Bitai.LDAPHelper/AccountManager.cs

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions src/Bitai.LDAPHelper/Authenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte


#region Public methods
public async Task<DTO.LDAPDomainAccountAuthenticationResult> AuthenticateAsync(DTO.LDAPDomainAccountCredential credential, SearchLimits searchLimits, LDAPDomainAccountCredential credentialForSearching, string requestLabel = null) {
public async Task<LDAPDomainAccountAuthenticationResult> AuthenticateAsync(LDAPDomainAccountCredential credential, SearchLimits searchLimits, LDAPDomainAccountCredential credentialForSearching, string requestLabel = null) {
LDAPDomainAccountAuthenticationResult authenticationResult;

try {
Expand All @@ -33,8 +33,10 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
return new LDAPDomainAccountAuthenticationResult(credential, searchResult.OperationMessage, searchResult.ErrorObject, requestLabel);
}
else {
authenticationResult = new LDAPDomainAccountAuthenticationResult(credential, false, requestLabel, false);
authenticationResult.OperationMessage = searchResult.OperationMessage;
authenticationResult = new LDAPDomainAccountAuthenticationResult(credential, false, requestLabel, false)
{
OperationMessage = searchResult.OperationMessage
};

return authenticationResult;
}
Expand Down Expand Up @@ -62,7 +64,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
authenticated = false;
}

authenticationResult = new DTO.LDAPDomainAccountAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
authenticationResult = new LDAPDomainAccountAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
if (authenticated.Value)
authenticationResult.SetSuccessfulOperation($"The domain username {credential.DomainName}\\{credential.AccountName} has been successfully authenticated.");
else
Expand All @@ -71,7 +73,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
return authenticationResult;
}
catch (Exception ex) {
return new DTO.LDAPDomainAccountAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DomainAccountName}", ex, requestLabel);
return new LDAPDomainAccountAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DomainAccountName}", ex, requestLabel);
}
}

Expand All @@ -80,7 +82,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
/// </summary>
/// <param name="credential"><see cref="Credentials"/> to connect and authenticate on the LDAP Server.</param>
/// <returns>True or false, if authenticated or no.</returns>
public async Task<DTO.LDAPDomainAccountAuthenticationResult> AuthenticateAsync(DTO.LDAPDomainAccountCredential credential, string requestLabel = null) {
public async Task<LDAPDomainAccountAuthenticationResult> AuthenticateAsync(LDAPDomainAccountCredential credential, string requestLabel = null) {
try {
bool? authenticated;
using (var connection = await GetLdapConnection(this.ConnectionInfo, credential, false)) {
Expand All @@ -90,7 +92,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
authenticated = false;
}

var result = new DTO.LDAPDomainAccountAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
var result = new LDAPDomainAccountAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);

if (authenticated.Value)
result.SetSuccessfulOperation($"The domain username {credential.DomainAccountName} has been successfully authenticated.");
Expand All @@ -100,11 +102,11 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
return result;
}
catch (Exception ex) {
return new DTO.LDAPDomainAccountAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DomainAccountName}", ex, requestLabel);
return new LDAPDomainAccountAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DomainAccountName}", ex, requestLabel);
}
}

public async Task<DTO.LDAPDistinguishedNameAuthenticationResult> AuthenticateAsync(DTO.LDAPDistinguishedNameCredential credential, SearchLimits searchLimits, LDAPDomainAccountCredential credentialForSearching, string requestLabel = null) {
public async Task<LDAPDistinguishedNameAuthenticationResult> AuthenticateAsync(LDAPDistinguishedNameCredential credential, SearchLimits searchLimits, LDAPDomainAccountCredential credentialForSearching, string requestLabel = null) {
LDAPDistinguishedNameAuthenticationResult authenticationResult;

try {
Expand Down Expand Up @@ -150,7 +152,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
authenticated = false;
}

authenticationResult = new DTO.LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
authenticationResult = new LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
if (authenticated.Value)
authenticationResult.SetSuccessfulOperation($"The account with DN: {credential.DistinguishedName} has been successfully authenticated.");
else
Expand All @@ -159,11 +161,11 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
return authenticationResult;
}
catch (Exception ex) {
return new DTO.LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DistinguishedName}", ex, requestLabel);
return new LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DistinguishedName}", ex, requestLabel);
}
}

public async Task<DTO.LDAPDistinguishedNameAuthenticationResult> AuthenticateAsync(DTO.LDAPDistinguishedNameCredential credential, string requestLabel = null) {
public async Task<LDAPDistinguishedNameAuthenticationResult> AuthenticateAsync(LDAPDistinguishedNameCredential credential, string requestLabel = null) {
try {
bool? authenticated;
using (var connection = await GetLdapConnection(this.ConnectionInfo, credential, false)) {
Expand All @@ -173,7 +175,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
authenticated = false;
}

var result = new DTO.LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);
var result = new LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), authenticated.Value, requestLabel);

if (authenticated.Value)
result.SetSuccessfulOperation($"The account with DN: {credential.DistinguishedName} has been successfully authenticated.");
Expand All @@ -183,7 +185,7 @@ public Authenticator(ConnectionInfo connectionInfo, ILdapConnectionFactoryAdapte
return result;
}
catch (Exception ex) {
return new DTO.LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DistinguishedName}", ex, requestLabel);
return new LDAPDistinguishedNameAuthenticationResult(credential.SecureClone(), $"Failed to authenticate {credential.DistinguishedName}", ex, requestLabel);
}
}
#endregion
Expand Down
11 changes: 6 additions & 5 deletions src/Bitai.LDAPHelper/BaseHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Bitai.LDAPHelper.LdapAdapters;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Bitai.LDAPHelper.Extensions;
using Bitai.LDAPHelper.LdapAdapters;

namespace Bitai.LDAPHelper
{
Expand Down Expand Up @@ -195,7 +196,7 @@ protected IEnumerable<string> GetRequiredAttributeNames(DTO.RequiredEntryAttribu
default:
throw new ArgumentOutOfRangeException("requiredEntryAttributes");
}
}
#endregion
}
}
}
#endregion
}
}
8 changes: 4 additions & 4 deletions src/Bitai.LDAPHelper/Bitai.LDAPHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<Product>LDAP Services Wrappers</Product>
<Description>Library to wrap Novell.Directory.Ldap.NETStandard functionality to make LDAP common queries to search accounts and objects in a Directory Service.</Description>
<Copyright>© 2026 BITAI. All rights reserved.</Copyright>
<Version>10.1.0</Version>
<AssemblyVersion>10.1.0</AssemblyVersion>
<PackageIcon>hierarchy_32.png</PackageIcon>
<FileVersion>10.1.0</FileVersion>
<Version>10.1.2</Version>
<AssemblyVersion>10.1.2</AssemblyVersion>
<FileVersion>10.1.2</FileVersion>
<PackageIcon>hierarchy_32.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Bitai.LDAPHelper</PackageId>
<AssemblyName>Bitai.LDAPHelper</AssemblyName>
Expand Down
20 changes: 20 additions & 0 deletions src/Bitai.LDAPHelper/DataValidationException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Bitai.LDAPHelper
{
[Serializable]
public class DataValidationException : Exception
{
public DataValidationException()
{
}

public DataValidationException(string message) : base(message)
{
}

public DataValidationException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
Loading
Loading