SignInManager.SignInByLogonParameters(Object) Method
Signs in a user based on the specified user logon parameters.
Namespace: DevExpress.ExpressApp.Security
Assembly: DevExpress.ExpressApp.Security.v25.1.dll
NuGet Package: DevExpress.ExpressApp.Security
Declaration
Parameters
| Name | Type | Description |
|---|---|---|
| logonParameters | Object | An object that contains a user’s logon parameters. |
Returns
| Type | Description |
|---|---|
| DevExpress.ExpressApp.Security.AuthenticationResult | An object of the |
Remarks
Use this method to programmatically sign a user into an XAF application. This method takes an object that contains a user’s logon parameters and returns an AuthenticationResult object.
The returned object exposes the following properties.
Succeeded- A
booleanproperty that indicates whether or not the authentication attempt was successful. Principal- If the authentication succeeds, this property contains the ClaimsPrincipal (a collection of statements about the authenticated user) returned by the Security System.
Error- If the authentication fails, this property contains the resulting Exception.
The following code snippet demonstrates how to use the SignInByLogonParameters method:
using DevExpress.ExpressApp.Security;
using Microsoft.Extensions.DependencyInjection;
// ...
// Use Dependency Injection to access the IServiceProvider.
var signInManager = serviceProvider.GetRequiredService<SignInManager>();
var authResult = signInManager.SignInByLogonParameters(new AuthenticationStandardLogonParameters("User", "Password"));
Usage Considerations
- The
SignInByLogonParametersmethod differs from the AuthenticateByLogonParameters method in the following ways:- The
AuthenticateByLogonParametersmethod only uses the passed logon parameters to find a user. This method does not affect the currently logged in user. - The
SignInByLogonParametersmethod implicitly calls theAuthenticateByLogonParametersmethod to find a user. If the user is found,SignInByLogonParameterssigns in this user.
- The
- When called, all of the
UserManager.SignIn*methods first ensure that no user is logged in within the current scope. Note that in WinForms applications this guarantees that no user is logged in at all. Blazor apps allow multiple active scopes, so the same guarantee does not apply. If a user is already logged in, these methods throw theInvalidOperationExceptionwith the following message: “Authentication failed: security user already initialized.”.
See Also