Re: Form Authentication and logged in users (newbie)

From: Brock Allen (ballen_at_NOSPAMdevelop.com)
Date: 11/18/05


Date: Fri, 18 Nov 2005 07:43:27 -0800

I'm not 100% sure of what you're looking for, but I think what you want is
this:

Dim IDAgenzia as Integer
IDAgenzia = CType(ds.Tables("tblCredenziali").Rows(1), Integer)

CType will cast (or convert as necessary) the object to an Integer.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hello Brock,
> thanks for the hints, I have looked at your resources
> I am trying to do my homework but I am struggling a little. This is
> what I
> have produced so far...following your suggestion to store data in the
> cache.
> In the login page I have the following code (I have omitted some for
> brevity)
>
> ...... ' I open the connection
>
> ' Create OleDbCommand to select pwd field from
> the
> users table given a supplied userName.
> cmd = New OleDbCommand("Select strPassword,
> IDAgenzia
> from tblCredenziali where strUserName=@userName", conn)
> cmd.Parameters.Add("@userName",
> OleDbType.VarChar, 25)
> cmd.Parameters("@userName").Value = userName
> ' Execute command and fetch pwd field into
> lookupPassword string. SUGGESTION OF THE MICROSOFT ARTICLE
> lookupPassword = cmd.ExecuteScalar() ' so it
> retrieves
> the one value coming form that record
> ' My own juice is the following...IDAgenzia is the
> unique key that identifies what I need in order to bind future dataset
> based on that id
>
> Dim objDA as New OleDbDataAdapter(Cmd)
> Dim ds As New DataSet()
> objDA.Fill(ds)
> Dim IDAgenzia As Object ' I deserve
> a
> whip with a stick on my backhand for this but "object" was the only
> type
> that
>
> ' didn't retun an error...I tried String, and Integer (which should
> be the one need to be used since it is an )
>
> ' If you have a word of advice here too would be greatly appreciated
>
> IDAgenzia = ds.Tables("tblCredenziali").Rows(1)
> ' here I am trying to grab the ID resulting from the query command
>
> Cache.Insert("Agenzia", IDAgenzia, Nothing,
> DateTime.Now.AddMinutes(1), TimeSpan.Zero) ' here I see that the
> value is
> available from within the application, but what if a second user logs
> in
> after 30 seconds from the first one. Will be the value still
> available and
> free? I got the following error:
> Description: HTTP 404. The resource you are looking for (or one of its
> dependencies) could have been removed, had its name changed, or is
> temporarily unavailable. Please review the following URL and make sure
> that
> it is spelled correctly.
> ' Cleanup command and connection objects.
> cmd.Dispose()
> conn.Dispose()
> Again thanks for your help in advance.
> Lorenzo
> "Brock Allen" <ballen@NOSPAMdevelop.com> ha scritto nel messaggio
> news:b8743b114b71f8c7b9a257a59e1a@msnews.microsoft.com...
>
>> You need to look into the various forms of state management. Off the
>> top of my head you have 3 options:
>>
>> 1) Always go back to the database every time for whatever data you
>> need 2) Upon login load the commonly used data and store it in
>> session state 3) Demand load the data and store it in the data cache
>>
>> The downside of #1 is that you'll make lots of roundtrips to the
>> database for the same data. This is wasteful. The downside with #2 is
>> that session is brittle if stored InProc (which is the default) and
>> it's somewhat inefficient if you use an Out of Proc mode. The upside
>> of #2 is that it's fairly easy. Personally I like #3, as it's a
>> compromise.
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>> Hello I appreciate some guidance on Form based authentication. On a
>>> training project I successfully log in and off users with simple the
>>> simple
>>> Form authentication.
>>> I am not storing credentials on the webconfig but on a DataBase, I
>>> followed
>>> the article from Microsoft at the following address:
>>> http://support.microsoft.com/default.aspx?scid=kb;en-us;308157
>>> All works fine but how do I get the information from the user that
>>> has
>>> logged in on the protected page. On the page that the user reaches
>>> after logging in I might want to add his/her name and consequently
>>> any
>>> additional information. In my case I will be needing the ID of the
>>> user logged in to display related content.
>>> Where should I look for answers? Can you give also some resources
>>> where I can study on?
>>>
>>> Thank you in advance.
>>> Lorenzo



Relevant Pages

  • DpAPI Encrypted Aes Key Problems
    ... Friend Function CreateKeyAs String ... Dim aesProvider As New RijndaelManaged ... Public Enum Store ... ' Not passing optional entropy and use the machine store ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Storing a value for later use in vba or a Macro
    ... Dim strCurrentCustomer as String ... do you programmatically store a value from one record to use in ...
    (microsoft.public.access.gettingstarted)
  • RE: .movefile
    ... You should be able to store the file name in a variable after you open the ... 'This example move all Excel files from FromPath to ToPath. ... Dim FromPath As String ...
    (microsoft.public.excel.programming)
  • Re: Module Data Storage
    ... please note that the multi-select listbox is not designed to store data. ... that person's hobbies from the list of all possible hobbies. ... Private Sub ClearHobbySelections() ... Dim rs As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: May be a little sophisticated for me, but should work!
    ... number and fourteen - one for each store. ... Since you said it works when percents are entered, ... Dim strLinkCriteria As String ...
    (comp.databases.ms-access)