LDAPCP icon indicating copy to clipboard operation
LDAPCP copied to clipboard

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

Open desmondkung opened this issue 10 months ago • 21 comments

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")

desmondkung avatar Apr 05 '24 07:04 desmondkung

@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 avatar Apr 05 '24 09:04 Yvand

Hi @Yvand,

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

desmondkung avatar Apr 05 '24 09:04 desmondkung

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 avatar Apr 05 '24 09:04 desmondkung

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          : {}

desmondkung avatar Apr 05 '24 10:04 desmondkung

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()

Yvand avatar Apr 05 '24 10:04 Yvand

  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 avatar Apr 05 '24 11:04 desmondkung

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.

desmondkung avatar Apr 05 '24 11:04 desmondkung

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

Yvand avatar Apr 05 '24 11:04 Yvand

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

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

desmondkung avatar Apr 06 '24 04:04 desmondkung

@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?

Yvand avatar Apr 08 '24 14:04 Yvand

@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?

desmondkung avatar Apr 08 '24 14:04 desmondkung

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

Yvand avatar Apr 08 '24 14:04 Yvand

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

desmondkung avatar Apr 09 '24 05:04 desmondkung

@desmondkung the error happens because there is no group claim type set in the trust in your environment. I opened PR https://github.com/Yvand/LDAPCP/pull/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)

Yvand avatar Apr 11 '24 12:04 Yvand

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

desmondkung avatar Apr 11 '24 12:04 desmondkung

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

desmondkung avatar Apr 12 '24 01:04 desmondkung

weird that I did not repro it, but it should be fixed in https://github.com/Yvand/LDAPCP/commit/b4c5d9703f94fb279dd608f1c34a03365ba4c24f

Yvand avatar Apr 12 '24 14:04 Yvand

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

desmondkung avatar Apr 14 '24 03:04 desmondkung

I just published a nightly build which contains this fix

Yvand avatar Apr 15 '24 08:04 Yvand

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!

desmondkung avatar Apr 15 '24 09:04 desmondkung

Thanks for confirming!

Yvand avatar Apr 15 '24 11:04 Yvand