Export (0) Print
Expand All

UserNamePasswordValidator Class

Validates a username and password.

Namespace: System.IdentityModel.Selectors
Assembly: System.IdentityModel (in system.identitymodel.dll)

public abstract class UserNamePasswordValidator
public abstract class UserNamePasswordValidator
public abstract class UserNamePasswordValidator
Not applicable.

Use the UserNamePasswordValidator class to specify how a username and password is validated. This can be done by deriving a class from UserNamePasswordValidator and override the Validate method.

public class MyCustomUserNameValidator : UserNamePasswordValidator
{
    // This method validates users. It allows two users, test1 and test2 
    // with passwords 1tset and 2tset respectively.
    // This code is for illustration purposes only and 
    // MUST NOT be used in a production environment because it is NOT secure.    
    public override void Validate(string userName, string password)
    {
        if (null == userName || null == password)
        {
            throw new ArgumentNullException();
        }

        if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
        {
            throw new SecurityTokenException("Unknown Username or Password");
        }
    }
}

System.Object
  System.IdentityModel.Selectors.UserNamePasswordValidator

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft