DataSource Controls :: BLL And Membership.getuser()?

Feb 23, 2010

I have a TableAdapter that queries a table by UserName. The TableAdapter works fine if I preview data and supply a username. I'm trying to become more familiar with BLLs . I can't find any good examples on using the BLL as the datasource and supply the membership.getuser().username to the DAL. Here is what I tried so far, but membership.getuser can not be a string.

Imports DataSet1TableAdapters
Public
Class UserProfilesBLL
Private UserProfilesAdapter
As UserProfilesTableAdapter =
Nothing
Protected
ReadOnly
Property Adapter()
As UserProfilesTableAdapter
Get
If UserProfilesAdapter
Is
Nothing
Then
UserProfilesAdapter =
New UserProfilesTableAdapter()
End
If
Return UserProfilesAdapter
End
Get
End
Property
Public
Function GetDataByUserName(ByVal
serName As
String)
As DataSet1.UserProfilesDataTable
Dim u
As MembershipUser
u = Membership.GetUser().UserName.ToString
Return Adapter.GetDataByUserName(u)
End
Function
End
Class

View 2 Replies


Similar Messages:

Security :: How To Override Membership.GetUser()

Sep 22, 2010

i have add a new column (CustomeAuth) to aspnet_Users but i need to get the value of this column just like:

Membership.GetUser().UserName

so i can use :

Membership.GetUser().CustomeAuth

View 3 Replies

Membership.GetUser() Vs Context.User?

Apr 29, 2010

What are the differences between Membership.GetUser() and Context.User, and which is recommended for use in getting information about the current user?

View 2 Replies

Security :: Membership.GetUser() Using FireFox Browser

Jun 2, 2010

I am finishing up my asp.net web application targeting .net 4.0. I am using VS2010.

I have deployed my application to a host server and now I am testing with multiple different browsers.

The first issue I ran into comes down to the following code:

[Code]....

If I use IE, login and click something that causes the above code to execute then currentUser is NOT null. However doing the exact same steps in FireFox currentUser is null, even though I know I am logged in as my name and other indications on the webpage confirms I am.

------------------------

Update

----------------------

Since originally posting this thread I have done more testing.

I placed a test button on a random page and the button click will update a label on that page indicating if the currentUser is null or not. This button works both in IE and in FireFox. Also both running locally and running on the host server.

----------------------

So now I am looking at what is different about the one place it appears not to work so let me try to make this clear.

I use a component called Uploadify to upload images into a database. That component calls a page/request called ImageUploader.ashx which inherits from IHttpHandler. Here is all the pertainent code from that file.
[Code]....

The problem is when calling from FireFox, imgProvider.Status = null. This is a problem because the ImageProvider will try to insert a record into my database and the column for Status cannot be null so that causes it to crash. I made the change to detect if Status = null and return the user id if so as an error message to help me debug. To understand how Status is set you only have to look at a little code in the ImageProvider class:

[Code]....

You will notice when the ImageProvider is created it calls ClearFields(). Inside ClearFields() is where it gets the currentUser and if not null it sets the UserID property, which case the setter for UserID must set Status to either Approved or Pending. Whats happening is ONLY in FireFox, and after more testing, ONLY on the host server does currentUser = null even when I am logged in. but in other areas of code I can get currentUser and it works, also this works fine with IE, it also works fine with FireFox running locally. So I have icolated it down to this specific piece of code, when using FireFox, when running on Host server.

View 9 Replies

Security :: Membership.GetUser().UserName On Login Page?

Oct 16, 2010

I have an Employee class in my App_Code folder. On my login page I am trying to create an Employee using the asp.net username as a parameter in my Employee constructor.

I have tried creating the employee in the page load event when it is a post back. I have tried doing it in the Login1_LoggedIn event. For some reason I cannot pull the username in either one of these places, but if I redirect after logging in and do the same thing on another page, it works.

How can I get it done on the login page?

[Code]....

View 3 Replies

Security :: Membership.GetUser(object ProviderUserKey) Throws InvalidCastException In .NET 2.0?

Jan 10, 2011

I have an application that has been running for about 1.5 years. Suddenly, I got a bug report that the support team are receiving an InvalidCastException in the User ManagerUnable to cast object of type 'System.Guid' to type 'System.String'. The line this appears to be happening on is:

string queryStringID = Session["EditID"].ToString();
Guid providerUserKey =
new
Guid(queryStringID)
MembershipUser user =
Membership.GetUser(providerUserKey);
<--- here

This is a rather strange error as the value of the queryStringID is in fact a Guid generated by the Membership.GetUser(UserName).ProviderUserKey on the previous page. It doesn't seem to make any sense at all. I'm using the built-in SqlMembershipProvider with no changes. It's as if it isn't picking up that it should be using the overloaded function Membership.GetUser(object providerUserKey)Anyone else ever seen anything like this? I wouldn't normally post here unless I was absolutely stuck but I can't seem to find any relevant information by Googleing this one. Also, it's just started doing this. There was never an issue before. Very strange

View 5 Replies

Security :: Membership.getuser() Returns Null In Ff And Chrome But Works Fine In IE

Mar 29, 2010

I have strange problem with the membership provider on my mvc application.

I have a webforms page inside admin folder which calls the following code in the models directory.

public int SaveUploadedFile(HttpPostedFileBase fileBase)

View 2 Replies

Intermittent Membership.GetUser() Error - Unable To Cast Object Of Type System.Guid?

Jan 24, 2011

This error is occuring randomly, and I can't seem to pinpoint what is causing it. For the most part, the code works fine. I'm confused why it works sometimes, but then suddently craps out on me, lol.It happens in the code when I call upon the asp.net membership provider. It only seems to happen when i use Membership.GetUser() to grab the logged in user's information.

View 9 Replies

DataSource Controls :: Membership Providers - Error

Jun 3, 2010

I am now using SQL Server 2008 EXPRESS x64 on a PC running WINDOWS 7 ULTIMATE x64 bit.

how to configure ASP.Net Membership Providers because I can't attach a database created after this example :

http://aquesthosting.headtreez.com/doc/29423088-74cd-4d51-b2ee-3cb958f08d1a

(I have created runproviders.sql with my Visual Studio x64 Win64 Command Prompt (2010) )

Still now working...

Every time I run ASP.NET Configuration -> Provider -> Select a single provider for all site management data and TEST for

AspNetSqlProvider

I get the following error every time :

"Could not establish a connection to the database.

If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."

I can tell you for sure that my new created database is working because i used a web page with a CreateUserWizard1 control and I can create new users.Even I can see the new creted user with ASP.NET Configuration -> Security.

View 2 Replies

DataSource Controls :: How To Handle Membership Info Among Multiple Databases

May 13, 2010

I'm creating a site that will offer several different services (blogs, videos, images..), all under the same site.

Each service will use a separate database and all services must use the same membeship info. Users will only need one login to access all these services.

For the membership database i will use the default aspnetdb database.

There are two ways i can think of:

1) Use a join-query between two databases, each time i want to show some service records per user.

2) Create a custom membership-info table in each service's database, and keep it in sync with the master membership table in aspnetdb database.

The custom membership table will be like this:

Id - int, primary, identity
UserId - uniqueidentifier (of aspnetdb database)

What is the best way to do this in the long run, when i will have six or seven or more services ?

View 2 Replies

DataSource Controls :: Copying SQL Server Database Has Not Copied Membership Stuff Correctly?

Jan 19, 2010

I have just used the Import and Export Wizard to copy my production SQL Server database, which uses Membership and Roles. I used the option to copy all the data from existing tables and views and did not modify the mapping in any way. Things do not seem to have gone well.....

My source database has a bunch of views with names like vw_aspnet_Applications,vw_aspnet_MembershipUsers, etc. The copy database has these listed as tables!I wondered if running aspnet_regsql.exe might fix things. I needed to run this anyway to create all the missing stored procedures for Membership, etc. However, it failed with the error:Setup failed.Exception:An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 2714 and the SqlException message is: There is already an object named 'vw_aspnet_Applications' in the database.Creating the vw_aspnet_Applications view...I am a bit lost. All I want to do is to create a total clone of my production database for test purposes. Where do I go from here?

View 11 Replies

Security :: GetUser() Does Not Exist?

Dec 2, 2010

This has got to be simple so I am just going to post my code and then list the error I am getting:

[Code]....

When I do a build I get the following error message:

The type or namespace name 'GetUser' does not exist in the namespace 'ScoutingAssistant.Membership' (are you missing an assembly refrence?)

Now if I change Membership.GetUser() to System.Web.Security.Membership.GetUser() it works just fine. But I thought by adding:

using System.Web.Security;

to the top of the unit would prevent me from have to prefix Membership but it seems to be ignoring my using statement.

View 4 Replies

VS 2010 - How To Add Paging To Repeater That Uses Membership Provider As Datasource

Feb 28, 2012

I am using a custom membership provider. I needed to bind a repeater to a membershipusercollection but the only way I could think of was this:

There is no method to return a lcollection of membership users by userid. I basically have a friends table with a userid and a frienduserid field. both are foreign keys to the user table. So say I am userid 1 and I have two friends userid 2 and userid 3.

I needed to get a collection of membership users who are my friends (user 2 and 3)

So I did this:

Code:
Dim lstAccountIDs As List(Of Integer) = bl.GetFriendsAccountByUserID(iUser)
Dim mUsers As New MembershipUserCollection
For Each a In lstAccountIDs
mUsers.Add(Membership.GetUser(a))
Next

I get their id's and add them to to list(of Integer) then I loop through the list and get the particular user by id and add them to a membershipusercollection object.

I now need to add paging to my repeater control that uses that collection as a datasource. However the membership provider doesn't give me the ability to specify a pageindex or pagesize etc. It gives me those options in the GetAllUsers function but I need it to work in the above scenario.

View 1 Replies

WCF / ASMX :: GetUser() Is Null When WCf In Virtual Directory Is Called In Parent Directory

Nov 10, 2010

I have a WCF service in a virtual directory that is called in the code behind of a page that is in the parent directory, when i debug the code i can see the wcf service is being called, however when the service calls Membership.GetUser() it alway returns null. The user has already logged in to the asp.net site. When i call the service via jquery it does pick up the correct user, but i need to be able to call it via the code behind as well. I am developing in .Net 3.5 how i can make the Wcf pick up the logged in user?

View 3 Replies

DataSource Controls :: Failed To Update Database "C:MEMBERSHIP.MDF" Because The Database Is Read-only

Feb 8, 2010

This is a very common error as evidenced but the very large number of problems and suggested solutions on the web. I finally got around it last week but can't remember what was the step that did it. At that time, I was building a web application rather than a web site. Is that the difference? As you can see, it is no longer in the APP_DATA folder and is named membership.mdf rather than aspnetdb.mdf. I ran aspnet_regsql.exe to create it and actually had it working and was updating it successfully. But for other reasons, I had to scrap the application and decided to re-create it from scratch as a web site rather than a web application. I had been using Visual Studio 2008 to build the web application but am now using Visual Web Developer 2008 Express Edition to build the web site. Unfortunately, the Visual Studio application will no longer open so I can't verify that the web application still works. Can anybody help? (Please!!!) BTW, ASPNET and NETWORK SERVICE both have full control over the membership.mdf.

View 1 Replies

Pass Membership Logged In Username As Parameter To SQL Server Datasource Query

Jul 23, 2012

I have an ASP.NET VB website in which I am using the Membership functionality to authenticate users. I am doing this through the Login control on the HTML page. I have working that it will authenticate the user and then opens a welcome screen in which I have a button they can push to open a Reports.aspx page. On that page I have a dropdown box that is being populated from a datasource connection query to my SQL Server database table. It is a hard coded query but want it to query the table off the username text value that the user provided on the login (i.e. select <something> from inventory where username = <username>). I have not behind code but only HTML at this point. Here it is ... 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

[Code] .....

Here is the Reports form that has the dropdown on it:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Report.aspx.vb" Inherits="Report" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

[Code] .....

View 1 Replies

Security :: Custom Membership Provider Error "Could Not Load Type Custom.AspNet.Membership.PostPropertyProvider"

Jan 5, 2011

This is my first membership provider; I converted the sample provider [URL] to SQL. I created a vb class provider and put it into the App_Code folder. After it was created I tried to modify my webconfig but the error pops up. I don't know what else to try, I don't know if I have missed something

webconfig:

[code]....

View 1 Replies

C# - Membership Controls Reset Password Postback Error?

Mar 11, 2011

I have written a simple jQuery dialog box that will appear in an asp panel if the logged in user has not reset their password in the last 90 days. This is working great, however when the user types in their password and presses submit to insert the new password into the database, the parent page is posting back before the click event is fired on the user control.

Here is how it is set up:

default.aspx
<asp:Panel ID="pnlTest" runat="server" Visible="false">
<div id="dialog" title="Password must be reset">
<cms:ResetPassword runat="server" ID="reset" />

[Code]....

Whenever I click the button to change the password, the default page is calling a postback and it is blanking out the text that was input to change the password, so when the click function gets called the strings come through as "" and it throws an error.

View 1 Replies

Security :: Login Controls And Custom Membership Provider?

Oct 11, 2010

I am working on implementing a custom membership provider that works against an existing schema in my database and have a few thoughts/question.The login control will automatically call the ValidateUser method of the membership provider, so no matter how I implement the provider the only thing the login control cares about the bool value returned by this method. What I am confused about is there could be numerous reasons why a login attempt failed; user is locked out, too many tries in a period of time, etc. There is no way that I see to convey that to the control so it could display the proper message. Other properties of the membership provider such as PasswordStrengthRegularExpression have absolutely no effect on the login control as well (out of the box), I would have hoped that it would automatically somehow translate into regular expression validators, but that doesn't seem to be the case. So it seems that I need to initialize the login control properties with these settings out of the provider configuration if I want them to take on the control itself.

If the only thing that the Login control does out of the box (without manually handling events and doing the initialization as described above) is call the ValidateUser method on the membership provider, I see no way to convey back to the Login control why the validation failed or even doing things like throttling the validation requests based on a certain time window. Ultimately my question is why would I even use the membership provider then in conjunction with the login control? It seems like it was only designed for a Yes/No type response, which is very restrictive. If I want to build in logic with different messages back to the user I need to handle the login control events and call my own authentication classes that will handle all of my business requirements as well as return a custom error message back to the Login control to display to the user so they know why their attempt is invalid.

Unless I am wrong in my assumptions, it seems that the interface between the Login control as the membership API is too restrictive to be useful. Perhaps the API works better for other auth controls like ChangePassword better but for the actual Login control I don't see the point.

View 1 Replies

Forms Data Controls :: How To Delete Membership (user) In Gridview

Apr 1, 2010

The dafault database for membership does not allow Delete statement. So what should I do to delete the member from database as a Administrator.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserId" DataSourceID="SqlDataSource1" Width="800px">
<Columns>
<asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True"
SortExpression="UserId" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="CreateDate" HeaderText="CreateDate"
SortExpression="CreateDate" />
<asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate"
SortExpression="LastLoginDate" />
<asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate"
SortExpression="LastActivityDate" />
</Columns>
</asp:GridView>

View 2 Replies

Forms Data Controls :: Bind Membership Collection To GridView?

Mar 28, 2011

public void bindgrid()
{
MembershipUserCollection users= Syste.web.security.Membership.GetAllUsers();
Gridview1.datasource=users;
Gridview1.databind();
}

when I hover over the users using break point I have this userlist->non-public members->Values->[0] bill,[1] ian,[2] jeff-> comment,creation date,email,is approved, is locked out, is online, last activity date, name ...etc I want to bind name,creation date, email to my grid. Is users an object? Why am I not getting any fields if I use Users. ? But i get them as non-public members. How to bind to grid ? I never binded object to grid

View 1 Replies

Controls :: Membership Provider Login Error In Visual Studio 2013

May 7, 2015

I have create a new website with vs 2013, i have sql server 2008 data base on my server. I am using defautl memberships table of sql server for login and and roles. it works fine with vs 2010 but when i use the same web.config setting in vs 2013 and try to login it gives me following error.

Invalid column name 'Email'.
Invalid column name 'EmailConfirmed'.
Invalid column name 'PhoneNumber'.
Invalid column name 'PhoneNumberConfirmed'.

[Code] ....

View 1 Replies

Forms Data Controls :: Displaying All Users In A Grid Along With Profile And Membership Info?

Mar 24, 2010

I am developing a website in asp.net that user asp.net membership, users and profile tables.I am trying to display all the users that are registered in a grid along with their first name, last name, email and other profile information . unfortunately all this information is scattered in various tables in the database ( aspnet_users, profiles, membershipsetc)... Can you please tell me how to configfure the datasource & columns of my datagrid (control) to achieve what I am trying to do .. ?????

View 3 Replies

Forms Data Controls :: Creating A Custom-Bound GridView Using Membership Username?

Jan 26, 2011

I recently got a form to work with the "HttpContext.Current.User.Identity.Name.ToString" String. That basic idea was I needed a hidden form field so that each record submitted would include the UserName of the user logged in to the membership. However, whenever I try to create a custom query for the gridview, it doesn't submit. how I would go about doing this? Code as below:

[Code]....

[Code]....

View 2 Replies

DataSource Controls :: When Add A Object Datasource To Page, It Bring Only Common Layer Classes?

Mar 10, 2011

i have problem white Object datasource. i have a multi-tier Application that include common layer ,DAL Layer,business logic and persantation layerwhen i add a object datasource to my page, it bring me only common layer classes . but i want use bisuiness layer classes what do i do ?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved