473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

HOWTO: Programmatically Login User in ASP.Net 2.0

I want to bypass requiring the intranet domain user to type in a username and
password when coming to my website, even the very first time.

If it's the first time I do a Membership.CreatUser passing the username,
gotten from ServerVariables("LOGON_USER"), a constant password (all users
have the same password), and an email address built with the username and a
constant domain name from the intranet.

However, things like User.Identity.Name are still blank.

How do I programmatically login a user so that everything acts just like
when the user enters his username and password on a 'Login.aspx' page?
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
Jul 21 '06 #1
2 3972
Yo,

What you have to do is set an authentication cookie by doing the
following:

[c#]
FormsAuthentication.SetAuthCookie(userName, bool);

This way asp.net will load up the information for that username's info,
profile, etc.

If you need to manually load up the profile and gather some info first
before you do anything, use this:

ProfileCommon thisProfile = Profile.GetProfile(userName);

Good luck.

-Brenton

Dan Sikorsky wrote:
I want to bypass requiring the intranet domain user to type in a username and
password when coming to my website, even the very first time.

If it's the first time I do a Membership.CreatUser passing the username,
gotten from ServerVariables("LOGON_USER"), a constant password (all users
have the same password), and an email address built with the username and a
constant domain name from the intranet.

However, things like User.Identity.Name are still blank.

How do I programmatically login a user so that everything acts just like
when the user enters his username and password on a 'Login.aspx' page?
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
Aug 16 '06 #2
Thank you for the response. I'll try your recommendation(s).

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
"br*****@ungernet.com" wrote:
Yo,

What you have to do is set an authentication cookie by doing the
following:

[c#]
FormsAuthentication.SetAuthCookie(userName, bool);

This way asp.net will load up the information for that username's info,
profile, etc.

If you need to manually load up the profile and gather some info first
before you do anything, use this:

ProfileCommon thisProfile = Profile.GetProfile(userName);

Good luck.

-Brenton

Dan Sikorsky wrote:
I want to bypass requiring the intranet domain user to type in a username and
password when coming to my website, even the very first time.

If it's the first time I do a Membership.CreatUser passing the username,
gotten from ServerVariables("LOGON_USER"), a constant password (all users
have the same password), and an email address built with the username and a
constant domain name from the intranet.

However, things like User.Identity.Name are still blank.

How do I programmatically login a user so that everything acts just like
when the user enters his username and password on a 'Login.aspx' page?
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

Aug 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Philipp Ott | last post by:
Hello! I m looking for a solution to generate a digitally signed mime-email with linux/perl and to feed/pipe this then to sendmail. I found RFCs related to mime-signed etc. but somehow fail to...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
0
by: Dan | last post by:
hi ng, is there a way to set a custom login failed page when using windows authentification? my settings are: --------------------- <authorization> <allow users="x,y,z" /> <deny users="*"...
2
by: Dan Sikorsky | last post by:
My website users will all come from the same domain after they first login to the network in the morning; therefore I would like to use the benefits of Windows Authentication. But I would like to...
3
by: Dan Sikorsky | last post by:
How do you get a reference to the LoginStatus control contained in the LoginView control that resides on web.master? I need to determine if the LoginStatus will show a LogOut link(for a logged...
10
by: perplexed | last post by:
After a user logs in (ASP.NET 2.0 membership/roles), how do I programmatically access their UserId and other information stored in the ASP.NET database structure? A user may login at Login.aspx...
2
by: Pawel | last post by:
Howto: Programmatically serialization Entry Method Parameters ( their values ) ? See example below: public static void C(string Code, string Name) {
2
by: Sagaert Johan | last post by:
Hi How can i only allow downloading a file if a user has logged in ? I have an aspx page with links to downloadable files, a users needs to enter a login/pw before he can see the page, but if...
2
by: David | last post by:
Hello, I would like to know how to post form data programmatically. The idea is to get the intranet web page, programmatically entre the username and password in a login form, post it and be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.