-
Notifications
You must be signed in to change notification settings - Fork 0
Fix EnsureAttributes null handling and expand AD attribute contract to full Set-ADUser parameter set #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix EnsureAttributes null handling and expand AD attribute contract to full Set-ADUser parameter set #204
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1f4e9c5
Initial plan
Copilot 72dc475
Fix EnsureAttributes null handling; expand AD attribute contract; add…
Copilot 350e950
Address code review: simplify null check; use -Replace instead of -Ad…
Copilot 89e505c
Generalize SetUser using contract+LDAP func; remove LDAP hardcoding f…
Copilot 8652d30
SetUser: fetch ldapField directly from Get-IdleADAttributeLDAPField, …
Copilot a10be48
Update tests/Providers/ADIdentityProvider.Tests.ps1
blindzero 94d5943
Update src/IdLE.Provider.AD/Public/New-IdleADIdentityProvider.ps1
blindzero 9488180
Validate OtherAttributes is a hashtable in EnsureAttribute; add regre…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/IdLE.Provider.AD/Private/Get-IdleADAttributeLDAPField.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| function Get-IdleADAttributeLDAPField { | ||
| <# | ||
| .SYNOPSIS | ||
| Returns the verified LDAP attribute name for a given AD attribute key. | ||
|
|
||
| .DESCRIPTION | ||
| Provides the authoritative mapping from friendly AD attribute names (as used in the | ||
| IdLE AD Provider contract) to their verified LDAP schema attribute names. | ||
|
|
||
| LDAP names are verified against the Windows Server Active Directory LDAP schema. | ||
| This mapping is used for -Clear, -Replace, and -Add operations in Set-ADUser to | ||
| ensure correct attribute targeting in the directory. | ||
|
|
||
| .PARAMETER AttributeName | ||
| The friendly attribute name (PowerShell parameter name or contract key) to look up. | ||
|
|
||
| .OUTPUTS | ||
| System.String | ||
| The LDAP attribute name, or $null if the attribute is not a named parameter mapping. | ||
|
|
||
| .EXAMPLE | ||
| Get-IdleADAttributeLDAPField -AttributeName 'GivenName' | ||
| # Returns: 'givenName' | ||
|
|
||
| .EXAMPLE | ||
| Get-IdleADAttributeLDAPField -AttributeName 'EmailAddress' | ||
| # Returns: 'mail' | ||
| #> | ||
| [CmdletBinding()] | ||
| [OutputType([string])] | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string] $AttributeName | ||
| ) | ||
|
|
||
| # Verified against Windows Server Active Directory LDAP schema documentation. | ||
| # Sources: RFC 4519, RFC 2798 (inetOrgPerson), MS-ADSC (Active Directory Schema Classes/Attributes). | ||
| $ldapFields = @{ | ||
| # Name Attributes | ||
| GivenName = 'givenName' # RFC 4519 section 2.12 | ||
| Surname = 'sn' # RFC 4519 section 2.32 | ||
| DisplayName = 'displayName' # MS-ADSC | ||
| Initials = 'initials' # RFC 2256 | ||
|
|
||
| # Identity Attributes | ||
| SamAccountName = 'sAMAccountName' # MS-ADSC | ||
| UserPrincipalName = 'userPrincipalName' # MS-ADSC | ||
|
|
||
| # Organizational Attributes | ||
| Description = 'description' # RFC 4519 section 2.5 | ||
| Department = 'department' # RFC 2798 section 2.2 | ||
| Title = 'title' # RFC 4519 section 2.38 | ||
| Company = 'company' # MS-ADSC | ||
| Division = 'division' # MS-ADSC | ||
| Office = 'physicalDeliveryOfficeName' # RFC 4519 section 2.24 | ||
| Organization = 'o' # RFC 4519 section 2.19 | ||
| EmployeeID = 'employeeID' # MS-ADSC | ||
| EmployeeNumber = 'employeeNumber' # RFC 2798 section 2.5 | ||
|
|
||
| # Contact Attributes | ||
| EmailAddress = 'mail' # RFC 2798 section 2.13 | ||
| OfficePhone = 'telephoneNumber' # RFC 4519 section 2.35 | ||
| MobilePhone = 'mobile' # RFC 2798 section 2.15 | ||
| HomePhone = 'homePhone' # RFC 2798 section 2.11 | ||
| Fax = 'facsimileTelephoneNumber' # RFC 4519 section 2.10 | ||
|
|
||
| # Address Attributes | ||
| StreetAddress = 'streetAddress' # RFC 4519 section 2.34 | ||
| City = 'l' # RFC 4519 section 2.16 (localityName) | ||
| State = 'st' # RFC 4519 section 2.33 (stateOrProvinceName) | ||
| PostalCode = 'postalCode' # RFC 4519 section 2.23 | ||
| Country = 'co' # RFC 2256 section 5.4 (full country name) | ||
| POBox = 'postOfficeBox' # RFC 4519 section 2.25 | ||
|
|
||
| # Web / Profile Attributes | ||
| HomePage = 'wWWHomePage' # MS-ADSC | ||
|
|
||
| # Relationship Attributes | ||
| Manager = 'manager' # RFC 4524 section 2.1 | ||
|
|
||
| # Account/Profile Path Attributes | ||
| HomeDirectory = 'homeDirectory' # MS-ADSC | ||
| HomeDrive = 'homeDrive' # MS-ADSC | ||
| ProfilePath = 'profilePath' # MS-ADSC | ||
| ScriptPath = 'scriptPath' # MS-ADSC | ||
| } | ||
|
|
||
| if ($ldapFields.ContainsKey($AttributeName)) { | ||
| return $ldapFields[$AttributeName] | ||
| } | ||
|
|
||
| return $null | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.