Is there way to pass username from SP to IdP ?

I am looking at a use case where the service provider will need to capture the user id (not password) to identify the target IDP. In this case, the requirement is to send the user id (that is already captured at service provider end) to IDP, so that IDP can pre-populate the user ID while asking for password to end user.

Is there a standard in SAML how this information can be passed from SP to IDP? I am using SP initiated SAML where SAMLRequest and RelayState will be passed from SP to IDP.

Thank you.

As per the SAML v2.0 specification, the standard way to send the user ID to the IdP is as the NameID field of the SAML authn request.

To do this you’ll need to call the SAMLServiceProvider.InitiateSSO overload that takes an SSOOptions object. Set the SSOOptions.RequestUserName property to the user ID.

Not all IdPs support this so I recommend checking with the IdP whether they do.