Click or drag to resize

UserTokenFactoryFindForUser Method

Find a user token associated with the specified user, return null if not found.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IUserToken FindForUser(
	IContext context,
	IUser user,
	string key,
	IServer server = null,
	Nullable<Guid> moduleGuid = null
)

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution.
user
Type: AskiaPortalCmnIUser
User associated with the token to find.
key
Type: SystemString
Key of the token to find.
server (Optional)
Type: AskiaPortalCmnIServer
Server of the token to find.
moduleGuid (Optional)
Type: SystemNullableGuid
Guid of the module that manage the object (if null use the CurrentModule).

Return Value

Type: IUserToken
Return null if the user token was not found or if the user within the context doesn't have enough right to access it
Examples

Find the user token for the specified user.

var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));   
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    throw contextValidation.Exception;
}
var userToken = UserTokenFactory.FindForUser(context, context.User, "SSO");
if (userToken != null)
{
    Console.WriteLine($"User token Id={userToken.Id} was found. Token={userToken.Token}");
}
else
{
    Console.WriteLine("The specified user token doesn't exist, or the current user within the context could not access it");
}
See Also