Skip to content

feat:update ldap package#753

Merged
MayueCif merged 5 commits intomainfrom
feat/update_ldap
Aug 6, 2025
Merged

feat:update ldap package#753
MayueCif merged 5 commits intomainfrom
feat/update_ldap

Conversation

@MayueCif
Copy link
Contributor

@MayueCif MayueCif commented Aug 6, 2025

  • Added UserAccountControl property in LdapUser.cs for managing user account control information.
  • Introduced UserAccountControl enum in UserAccountControl.cs to define various account control flags.
  • Updated _attributes array in LdapProvider.cs to include userAccountControl for LDAP queries.
  • Implemented parsing logic for userAccountControl in LdapProvider.cs to convert its value to the UserAccountControl enum.
  • Updated Novell.Directory.Ldap.NETStandard version in Masa.Utils.Ldap.Novell.csproj from 4.0.0-beta4 to 4.0.0 and added System.Linq.Async reference.

MayueCif added 2 commits June 24, 2025 10:49
Replaced the `ClientQueryAsync` method with `ClientQuery().ToListAsync()` in the `ResetAsync` implementation. The `ClientQueryAsync` method and its internal logic have been removed, streamlining the asynchronous query process and improving code readability and maintainability.
- Added `UserAccountControl` property in `LdapUser.cs` for managing user account control information.
- Introduced `UserAccountControl` enum in `UserAccountControl.cs` to define various account control flags.
- Updated `_attributes` array in `LdapProvider.cs` to include `userAccountControl` for LDAP queries.
- Implemented parsing logic for `userAccountControl` in `LdapProvider.cs` to convert its value to the `UserAccountControl` enum.
- Updated `Novell.Directory.Ldap.NETStandard` version in `Masa.Utils.Ldap.Novell.csproj` from `4.0.0-beta4` to `4.0.0` and added `System.Linq.Async` reference.
@MayueCif MayueCif requested a review from Copilot August 6, 2025 07:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the LDAP package to support user account control information and upgrades the LDAP library dependency to a stable version. The changes add the ability to query and manage user account control flags from LDAP, which is essential for determining user account status in Active Directory environments.

  • Added support for UserAccountControl property to track user account status flags
  • Upgraded Novell LDAP library from beta to stable version and added async LINQ support
  • Removed unused async client query method in OpenIdConnect cache implementation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Masa.Utils.Ldap.Novell.csproj Updated package versions and added System.Linq.Async dependency
LdapProvider.cs Added userAccountControl to LDAP query attributes and parsing logic
UserAccountControl.cs New enum defining LDAP user account control flags
LdapUser.cs Added UserAccountControl property to user model
SyncCache.cs Simplified client query method and removed unused async implementation

"objectSid", "objectGUID", "objectCategory", "objectClass", "memberOf", "name", "cn", "distinguishedName",
"sAMAccountName", "userPrincipalName", "displayName", "givenName", "sn", "description",
"telephoneNumber", "mail", "streetAddress", "postalCode", "l", "st", "co", "c"
"telephoneNumber", "mail", "streetAddress", "postalCode", "l", "st", "co", "c","userAccountControl"
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma before "userAccountControl". Should be "c", "userAccountControl" for consistency with other array elements.

Suggested change
"telephoneNumber", "mail", "streetAddress", "postalCode", "l", "st", "co", "c","userAccountControl"
"telephoneNumber", "mail", "streetAddress", "postalCode", "l", "st", "co", "c", "userAccountControl"

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +28

public enum UserAccountControl
{
Script = 1,
AccountDisabled = 2,
HomeDirectoryRequired = 8,
AccountLockedOut_DEPRECATED = 16,
PasswordNotRequired = 32,
PasswordCannotChange_DEPRECATED = 64,
EncryptedTextPasswordAllowed = 128,
TempDuplicateAccount = 256,
NormalAccount = 512,
InterDomainTrustAccount = 2048,
WorkstationTrustAccount = 4096,
ServerTrustAccount = 8192,
PasswordDoesNotExpire = 65536,
MnsLogonAccount = 131072,
SmartCardRequired = 262144,
TrustedForDelegation = 524288,
AccountNotDelegated = 1048576,
UseDesKeyOnly = 2097152,
DontRequirePreauth = 4194304,
PasswordExpired_DEPRECATED = 8388608,
TrustedToAuthenticateForDelegation = 16777216,
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UserAccountControl enum lacks XML documentation comments explaining its purpose and the meaning of the flags, which would be helpful for API consumers working with LDAP user account control values.

Suggested change
public enum UserAccountControl
{
Script = 1,
AccountDisabled = 2,
HomeDirectoryRequired = 8,
AccountLockedOut_DEPRECATED = 16,
PasswordNotRequired = 32,
PasswordCannotChange_DEPRECATED = 64,
EncryptedTextPasswordAllowed = 128,
TempDuplicateAccount = 256,
NormalAccount = 512,
InterDomainTrustAccount = 2048,
WorkstationTrustAccount = 4096,
ServerTrustAccount = 8192,
PasswordDoesNotExpire = 65536,
MnsLogonAccount = 131072,
SmartCardRequired = 262144,
TrustedForDelegation = 524288,
AccountNotDelegated = 1048576,
UseDesKeyOnly = 2097152,
DontRequirePreauth = 4194304,
PasswordExpired_DEPRECATED = 8388608,
TrustedToAuthenticateForDelegation = 16777216,
/// <summary>
/// Flags that control the behavior of user accounts in Active Directory (LDAP).
/// These values correspond to the userAccountControl attribute and are used as bitwise flags.
/// Some flags are deprecated and should not be used in new code.
/// </summary>
public enum UserAccountControl
{
/// <summary>
/// The logon script will be run.
/// </summary>
Script = 1,
/// <summary>
/// The user account is disabled.
/// </summary>
AccountDisabled = 2,
/// <summary>
/// The home directory is required.
/// </summary>
HomeDirectoryRequired = 8,
/// <summary>
/// The account is locked out. Deprecated: Use lockoutTime attribute instead.
/// </summary>
AccountLockedOut_DEPRECATED = 16,
/// <summary>
/// No password is required.
/// </summary>
PasswordNotRequired = 32,
/// <summary>
/// The user cannot change the password. Deprecated: Use ntSecurityDescriptor instead.
/// </summary>
PasswordCannotChange_DEPRECATED = 64,
/// <summary>
/// The user can use reversible encryption for the password.
/// </summary>
EncryptedTextPasswordAllowed = 128,
/// <summary>
/// This is a temporary duplicate account.
/// </summary>
TempDuplicateAccount = 256,
/// <summary>
/// This is a normal user account.
/// </summary>
NormalAccount = 512,
/// <summary>
/// This is a trust account for a domain.
/// </summary>
InterDomainTrustAccount = 2048,
/// <summary>
/// This is a computer account for a workstation.
/// </summary>
WorkstationTrustAccount = 4096,
/// <summary>
/// This is a computer account for a server.
/// </summary>
ServerTrustAccount = 8192,
/// <summary>
/// The password does not expire.
/// </summary>
PasswordDoesNotExpire = 65536,
/// <summary>
/// This is an MNS logon account.
/// </summary>
MnsLogonAccount = 131072,
/// <summary>
/// Smart card is required for logon.
/// </summary>
SmartCardRequired = 262144,
/// <summary>
/// The account is trusted for Kerberos delegation.
/// </summary>
TrustedForDelegation = 524288,
/// <summary>
/// The account is not trusted for delegation.
/// </summary>
AccountNotDelegated = 1048576,
/// <summary>
/// Use only DES encryption types for this account.
/// </summary>
UseDesKeyOnly = 2097152,
/// <summary>
/// Do not require Kerberos preauthentication.
/// </summary>
DontRequirePreauth = 4194304,
/// <summary>
/// The user's password has expired. Deprecated: Use pwdLastSet attribute instead.
/// </summary>
PasswordExpired_DEPRECATED = 8388608,
/// <summary>
/// The account is trusted to authenticate for delegation.
/// </summary>
TrustedToAuthenticateForDelegation = 16777216,
/// <summary>
/// This is a read-only domain controller account.
/// </summary>

Copilot uses AI. Check for mistakes.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

namespace Masa.Utils.Ldap.Novell.Entries;

Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the [Flags] attribute to this enum since UserAccountControl values are typically combined using bitwise operations in LDAP/Active Directory scenarios.

Suggested change
[Flags]

Copilot uses AI. Check for mistakes.
Removed the reference to the `System.Linq.Async` package
from the `Masa.Utils.Ldap.Novell.csproj` project file,
while keeping other package references intact.
Added comprehensive documentation for the `UserAccountControl` enum in `UserAccountControl.cs`, explaining the purpose and usage of each flag, including deprecated flags.

Removed unnecessary `using System.Collections.Generic;` statement in `LdapProvider.cs` and eliminated duplicate `userAccountControl` entry in the `_attributes` array to ensure uniqueness.
@MayueCif MayueCif merged commit 3970cef into main Aug 6, 2025
1 check passed
@MayueCif MayueCif deleted the feat/update_ldap branch August 6, 2025 07:37
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants