SqlMembershipProvider.GetUser Method (String, Boolean)

 

Returns information from the SQL Server membership database for a user and provides an option to update the last activity date/time stamp for the user.

Namespace:   System.Web.Security
Assembly:  System.Web (in System.Web.dll)

override GetUser : 
        username:string *
        userIsOnline:bool -> MembershipUser

Parameters

username
Type: System.String

The name of the user to get information for.

userIsOnline
Type: System.Boolean

true to update the last activity date/time stamp for the user; false to return user information without updating the last activity date/time stamp for the user.

Return Value

Type: System.Web.Security.MembershipUser

A MembershipUser object representing the specified user. If no user is found in the database for the specified username value, null is returned.

Exception Condition
System.ArgumentException

username exceeds 256 characters.

- or -

username contains a comma.

System.ArgumentNullException

username is null.

This method is called by the Membership class to retrieve user information from the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

If userIsOnline is true, the last activity date/time stamp for the user is updated to the current date and time. This is reflected in the LastActivityDate and IsOnline properties and in the value returned by GetNumberOfUsersOnline.

Leading and trailing spaces are trimmed from the username parameter value.

The following code example uses the GetUser method to determine whether a user exists before retrieving the password for the user.

System_CAPS_noteNote

This example uses the Membership class to call the SqlMembershipProvider specified as the defaultProvider in the Web.config file. If you need to access the default provider as the type SqlMembershipProvider, you can cast the Provider property of the Membership class. To access other configured providers as a specific provider type, you can access them by their configured name with the Providers property of the Membership class and cast them as the specific provider type.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: