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.
Assembly: System.Web (in System.Web.dll)
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.MembershipUserA 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.
Note |
|---|
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. |
Available since 2.0
.jpeg?cs-save-lang=1&cs-lang=fsharp)