Re: Use of Login Control



Doug,

The supplied code is in fact C# code. The VB.NET equivalent is:

Response.Write("Hello, " & Server.HtmlEncode(User.Identity.Name))
Dim id As FormsIdentity = CType(User.Identity, FormsIdentity)
Dim ticket As FormsAuthenticationTicket = id.Ticket
Response.Write("<p/>TicketName: " & ticket.Name)
Response.Write("<br/>Cookie Path: " & ticket.CookiePath)
Response.Write("<br/>Ticket Expiration: " & _
ticket.Expiration.ToString())
Response.Write("<br/>Expired: " & ticket.Expired.ToString())
Response.Write("<br/>Persistent: " & ticket.IsPersistent.ToString())
Response.Write("<br/>IssueDate: " & ticket.IssueDate.ToString())
Response.Write("<br/>UserData: " & ticket.UserData)
Response.Write("<br/>Version: " & ticket.Version.ToString())

Hope this helps,

Steve - dotneticated.com


"Chaplain Doug" <ChaplainDoug@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D8E62268-2811-4704-A24D-BAB75C90ED63@xxxxxxxxxxxxxxxx
Dear Manish:

I tried plugging the code into the default.aspx.vb and it would not work.
I
was able to kludge it and have some of it work. The code below is what I
produced. All the commented lines errored out. What am I missing? Is
the
example text C# code? How do I then reference in vb the items that
errored
out?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load

Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name))
'FormsIdentity id = (FormsIdentity)User.Identity;
'FormsAuthenticationTicket ticket = id.Ticket;

'Response.Write("<p/>TicketName: " + ticket.Name );
'Response.Write("<br/>Cookie Path: " + ticket.CookiePath);
'Response.Write("<br/>Ticket Expiration: " +
' ticket.Expiration.ToString());
'Response.Write("<br/>Expired: " + ticket.Expired.ToString());
'Response.Write("<br/>Persistent: " +
ticket.IsPersistent.ToString());
'Response.Write("<br/>IssueDate: " + ticket.IssueDate.ToString());
'Response.Write("<br/>UserData: " + ticket.UserData);
'Response.Write("<br/>Version: " + ticket.Version.ToString());
End Sub
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Manish Bafna" wrote:

Hi,
You will find Page_Load event in Default.aspx.cs(if language selected is
C#)
or in Default.aspx.vb(if language selected is VB.NET).When you double
click
Default.aspx in design mode you will get Default.aspx.cs. or
Default.aspx.vb.
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



"Chaplain Doug" wrote:

Thank you for the help. I have a question regarding the information to
which
you directed me. I am instructed:

Add a Page_Load Event Handler
Add the following code to the Page_Load event handler of your
Default.aspx
page. This page should be displayed only to authenticated users. To
prove
that this is the case, the code displays information obtained from the
forms
authentication ticket that is issued to authenticated users.

protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name));

FormsIdentity id = (FormsIdentity)User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;

Response.Write("<p/>TicketName: " + ticket.Name );
Response.Write("<br/>Cookie Path: " + ticket.CookiePath);
Response.Write("<br/>Ticket Expiration: " +
ticket.Expiration.ToString());
Response.Write("<br/>Expired: " + ticket.Expired.ToString());
Response.Write("<br/>Persistent: " + ticket.IsPersistent.ToString());
Response.Write("<br/>IssueDate: " + ticket.IssueDate.ToString());
Response.Write("<br/>UserData: " + ticket.UserData);
Response.Write("<br/>Version: " + ticket.Version.ToString());
}


I assume that this is aspx code. Where do I place this in the
default.aspx
file?

--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Manish Bafna" wrote:

Hi,
This is actually easy to-do with ASP.NET 2.0 using the
ActiveDirectoryMembership provider. Below msdn link describes how to
do it:
http://msdn2.microsoft.com/en-us/library/ms998360.aspx
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



"Chaplain Doug" wrote:

Visual Studio 2005 Express. I would like to have the login control
validate
logins using Active Directory. That is, I would like to have user
logins
checked against the AD in our server (Windows Server 2003). How
may I
accomplish this?
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


.



Relevant Pages

  • FormsAuthentication und schlaflose Nächte
    ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... string sEncTicket = FormsAuthentication.Encrypt; ... Die Rolle im Ticket aufzubewahren scheint mir das Naheliegenste zu sein. ... Auf der Logon Seite finde ich ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • Re: Forms Authentication in ASP.NET 2.0
    ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... // Encrypt the cookie using the machine key for secure transport ... That's pretty much all you need for the Forms Authentication without using ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Methods, Named Parameters
    ... > lingo) to be a useful way to document code. ... > ticket = new FormsAuthenticationTicket ... >>> Cheers, Pete ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using forms authentication for the first time
    ... You should create the ticket by your self. ... HttpCookie cookie = FormsAuthentication.GetAuthCookie; ... // Store roles inside the Forms cookie. ... FormsAuthenticationTicket newticket = new FormsAuthenticationTicket( ...
    (microsoft.public.dotnet.framework.aspnet.security)