Skip to content
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

[LDAPCPSE] After adding a LDAPS connection as second option, going to global config page will error out #203

Closed
desmondkung opened this issue Apr 5, 2024 · 21 comments · Fixed by #207
Assignees

Comments

@desmondkung
Copy link

Hi Yvand, after adding a LDAPS connection as a second option and saving it, going back to the global config page will error out with "Exception of type 'SystemArgumentException' was thrown. Parameter name: claimType.

I need help to see the current claimTypes via PowerShell and to edit them if necessary.
Based on old docs, I can add type using 'Assembly Name="Yvand.LDAPCPSE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80be731bc1a1a740" '

What about the second line? How do I adapt the following to fit LDAPCPSE?
$config = [ldapcp.LDAPCPConfig]::GetConfiguration("LDAPCPConfig")

@Yvand
Copy link
Owner

Yvand commented Apr 5, 2024

@desmondkung this is clearly unexpected. You can add an LDAPS entry using this PowerShell script:

Add-Type -AssemblyName "Yvand.LDAPCPSE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80be731bc1a1a740"
$config = [Yvand.LdapClaimsProvider.LDAPCPSE]::GetConfiguration()
$settings = $config.Settings

# Add a new lDAP Connection
$ldapConnection = New-Object "Yvand.LdapClaimsProvider.Configuration.LdapConnection"
$ldapConnection.LdapPath = "LDAP://contoso.local:636/DC=contoso,DC=local"
$ldapConnection.Username = "<account>"
$ldapConnection.Password = "<password>"
$ldapConnection.EnableAugmentation = $true
$settings.LdapConnections.Add($ldapConnection)
$config.ApplySettings($settings, $true)

To understand your scenario, can you send the output of this:

$trust = Get-SPTrustedIdentityTokenIssuer "YOUR_SPTRUST_NAME"
$trust.ClaimTypeInformation | fl MappedClaimType, IsIdentityClaim

@Yvand Yvand self-assigned this Apr 5, 2024
@desmondkung
Copy link
Author

Hi @Yvand,

MappedClaimType: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn
IsIdentityClaim: True

@desmondkung
Copy link
Author

Is there a way to reset all LDAPCPSE settings back to default via PowerShell so that I can try again? Including the removal of the recently added LDAPS connection.

@desmondkung
Copy link
Author

desmondkung commented Apr 5, 2024

current ldap settings

Identifier                           : fe5fe0de-8c6a-48f6-8fff-d28e704771b6
LdapPath                             : Connect to SharePoint domain
Username                             : 
Password                             : 
AdditionalMetadata                   : 
AuthenticationType                   : Secure, Signing, Sealing
UseDefaultADConnection               : True
EnableAugmentation                   : False
GetGroupMembershipUsingDotNetHelpers : False
GroupMembershipLdapAttributes        : {memberOf, uniquememberof}
LdapEntry                            : System.DirectoryServices.DirectoryEntry
LdapEntryServerAndPort               : LDAP://<removed>
InitializationSuccessful             : False
DomainName                           : 
DomainFQDN                           : 
DomaindistinguishedName              : 
UpgradedPersistedProperties          : {}

Identifier                           : 9b9ec788-ad57-44e8-841d-5dabc8107cac
LdapPath                             : LDAP://<removed>
Username                             : <domain\username removed>
Password                             : <removed>
AdditionalMetadata                   : 
AuthenticationType                   : Secure, Signing, Sealing
UseDefaultADConnection               : False
EnableAugmentation                   : False
GetGroupMembershipUsingDotNetHelpers : False
GroupMembershipLdapAttributes        : {memberOf, uniquememberof}
LdapEntry                            : System.DirectoryServices.DirectoryEntry
LdapEntryServerAndPort               : LDAP://<removed>
InitializationSuccessful             : False
DomainName                           : 
DomainFQDN                           : 
DomaindistinguishedName              : 
UpgradedPersistedProperties          : {}

@Yvand
Copy link
Owner

Yvand commented Apr 5, 2024

Is there a way to reset all LDAPCPSE settings back to default via PowerShell so that I can try again? Including the removal of the recently added LDAPS connection.

You can run those commands to delete and recreate the configuration:

[Yvand.LdapClaimsProvider.LDAPCPSE]::DeleteConfiguration()
[Yvand.LdapClaimsProvider.LDAPCPSE]::CreateConfiguration()

@desmondkung
Copy link
Author

  1. I've deleted and re-created the configuration via PowerShell by running those two commands.
  2. In central admin, I deleted the default LDAP connection to SharePoint domain and added only the LDAP server I want to connect to.
  3. Clicked on the "Test LDAP Connection" and it passed.
  4. Clicked on "Add LDAP Connection", then click on "OK" at the top.
  5. Back at the Security page, click on "Global configuration" and error appears.

@desmondkung
Copy link
Author

Another way to reproduce.

  1. Delete and re-create the configuration via PowerShell.
  2. In central admin, go to security, click on global configuration.
  3. Click on "OK" button at the top.
  4. Back at the Security page, click on "Global configuration" and error appears.

@Yvand
Copy link
Owner

Yvand commented Apr 5, 2024

Can you check the SharePoint log on the server running CA, filter on Produt/Area LDAPCP, and verify if errors/messages are recorded?

@desmondkung
Copy link
Author

desmondkung commented Apr 6, 2024

There's only 1 line if I filter ULS logs via Product.

"Successfully updated configuration 'LDAPCPSEConfig' with Id <guid>"

@Yvand
Copy link
Owner

Yvand commented Apr 8, 2024

@desmondkung the log is not giving more information. I would really like to understand the root cause: Are you able to repro the issue, whatever you type in the new LDAP connection? Can you repro if you remove the default LDAP connection?

@desmondkung
Copy link
Author

desmondkung commented Apr 8, 2024

@desmondkung the log is not giving more information. I would really like to understand the root cause: Are you able to repro the issue, whatever you type in the new LDAP connection? Can you repro if you remove the default LDAP connection?

I can try tomorrow morning.
To make sure I understand correctly, are you asking if I remove the default LDAP connection, leaving it with no LDAP connection, will the issue occur?

BTW, the log you referring to, does it include the ULS log I sent to your mail?

@Yvand
Copy link
Owner

Yvand commented Apr 8, 2024

Yes, basically I'm curious if you can reproduce the issue even with typing dummy data, e.g. LDAP://whatever.
Or, if it requires a specific test.
And also, if depends whever the default connection is present or not.
I'm sure it is a bug, but right now I cannot repro it. I hope I will be able to repro with your help

Yes, I reviewed the log you sent, and it contains nothing helpful

@desmondkung
Copy link
Author

Sent you 3 problem step recorder files for the following scenarios. All of them have identical error.

  1. With default LDAP
  2. With no LDAP
  3. With default LDAP and random LDAP

@Yvand
Copy link
Owner

Yvand commented Apr 11, 2024

@desmondkung the error happens because there is no group claim type set in the trust in your environment.
I opened PR #207 to handle this correctly.

In the meantime, you can fix the issue in the current version by removing the group claim type from the LDAPCPSE configuration, using the script below:

Add-Type -AssemblyName "Yvand.LDAPCPSE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80be731bc1a1a740"
$config = [Yvand.LdapClaimsProvider.LDAPCPSE]::GetConfiguration()
$settings = $config.Settings
$settings.ClaimTypes.Remove($settings.ClaimTypes.GroupIdentifierConfig)
$config.ApplySettings($settings, $true)

@desmondkung
Copy link
Author

Alright! I'll test this out tomorrow morning =)

@desmondkung
Copy link
Author

Error: Value cannot be null. Parameter name: type.

@Yvand
Copy link
Owner

Yvand commented Apr 12, 2024

weird that I did not repro it, but it should be fixed in b4c5d97

@desmondkung
Copy link
Author

I think the only way left to tell would be to deploy the new release once your pull request is done.

Yvand added a commit that referenced this issue Apr 15, 2024
* fix #203

* Update CHANGELOG.md

* update test in GroupIdentifierEncodedValuePrefix

* delete group claim type if None is selected
@Yvand
Copy link
Owner

Yvand commented Apr 15, 2024

I just published a nightly build which contains this fix

@Yvand Yvand added the bug label Apr 15, 2024
@desmondkung
Copy link
Author

desmondkung commented Apr 15, 2024

Just tested. No more error messages =) Will the release build be created soon? Else, I might just use this nightly first.
Thank you so much!

@Yvand
Copy link
Owner

Yvand commented Apr 15, 2024

Thanks for confirming!

@Yvand Yvand closed this as completed May 13, 2024
Yvand added a commit that referenced this issue May 13, 2024
* Update AssemblyInfo.cs

* Update GlobalSettings.ascx

* Update GlobalSettings.ascx

* Fix error if group claim type does not exist in the trust (#207)

* fix #203

* Update CHANGELOG.md

* update test in GroupIdentifierEncodedValuePrefix

* delete group claim type if None is selected

* Ignore case when comparing claim types (#205)

* ignore case when comparing claim types

* Update CHANGELOG.md

* Update CHANGELOG.md

* add server-side member NoValueSelected to test "None"

* Add property max search results count (#211)

* initial work

* work

* Fix uninitialized properties (#212)

* Update LDAPProviderConfiguration.cs

* remove deprecated pipelines

* test if ClaimsPrincipal.Identity is null

* Add helper methods to get/delete a directory connection in the configuration

* ask for confirmation before deleting connection

* fix repository name hosting the reusable workflows

* update build workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants