Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 11th, 2003, 03:26 PM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Windows Login via ASP.net

Is it possible to retrieve a user's windows login via asp.net?

Thanks

Renee C. Walker
__________________
Renee C. Walker
Reply With Quote
  #2 (permalink)  
Old November 12th, 2003, 12:05 AM
Authorized User
 
Join Date: Nov 2003
Location: hyderabad, AndhraPradesh, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koneruvijay
Default

The Q? is not clear.You would like to know whether the authentication can be done using windows login for an ASP.Net page?

Regards
Chanti

Reply With Quote
  #3 (permalink)  
Old November 13th, 2003, 02:26 PM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a way for me to capture the user's windows login via asp?

Renee C. Walker
Reply With Quote
  #4 (permalink)  
Old November 14th, 2003, 02:41 PM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a way for me to capture the user's windows login via asp?


Renee C. Walker
Reply With Quote
  #5 (permalink)  
Old November 14th, 2003, 04:01 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you use Windows authentication in an ASP.Net application, then you would be able to see their username.

I think this will do it:
HttpContext.Current.User.Identity.Name

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #6 (permalink)  
Old November 18th, 2003, 11:46 AM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you tell me where to put this code? I tried putting it in web.config and it's not working.

Thanks

Renee C. Walker
Reply With Quote
  #7 (permalink)  
Old November 18th, 2003, 01:29 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to put that code wherever you want to retrieve the login. I assume somewhere in your application you want to get that login username, so you have something like this...

sUserName = HttpContext.Current.User.Identity.Name



Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #8 (permalink)  
Old November 18th, 2003, 02:33 PM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, that's what I did. Let me check my code again.

Thanks for your help.

Renee C. Walker
Reply With Quote
  #9 (permalink)  
Old December 13th, 2003, 04:41 PM
Registered User
 
Join Date: Dec 2003
Location: New York, NY, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DamonCarr
Default

Use a class like the following:

using System;
using System.Security.Principal;
using System.Diagnostics;


namespace Credentials
{
    /// <summary>
    /// Summary description for USerInfo.
    /// </summary>
    public class cUserInfo
    {

        private WindowsPrincipal wpMain;


        public cUserInfo()
        {
            //
            // TODO: Add constructor logic here
            //

            // Put user code to initialize the page here
            wpMain = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            this._MachineName = System.Environment.MachineName;

        }


        public String UserName()
        {
            return wpMain.Identity.Name;
        }


        public bool IsUserInRole(String RoleName)
        {

            //We need to convert the string into an ID for the IsInRole call
            //WindowsBuiltInRole.Administrator

            return wpMain.IsInRole(this._MachineName + @"\" + RoleName);


        }

        public String AuthenticationType()
        {
                return wpMain.Identity.AuthenticationType;

        }

        private String _MachineName;

        public string MachineName
        {
            get { return this._MachineName; }
        }




    }
}

Also, does anyone know hoe to set IIS to anonymous access then have an ASPX form grab a user name and login, then log the user into Windows?

Thanks,
Damon Carr
Reply With Quote
  #10 (permalink)  
Old June 20th, 2007, 03:27 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

rwalker, Maybe you are looking for System.Environment.GetEnvironmentVariable("usernam e") ?
That worked for me

Just put debug mode on, and look at
System.Environment.GetEnvironmentVariables() and see the full list.. There are like 39 of them :)

Sameer

Author, http://www.SharpDeveloper.NET
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net login control kulkarnimonica ASP.NET 2.0 Professional 6 September 25th, 2007 05:22 PM
ASp.net 2.0 login name control kulkarnimonica ASP.NET 2.0 Professional 12 July 11th, 2007 12:42 AM
ASP.net login page in C# in 2.0 debjanib ASP.NET 2.0 Basics 4 March 23rd, 2007 08:46 AM
how to create login page using asp.net prakashbabu ASP.NET 2.0 Basics 1 March 7th, 2007 11:52 AM
Login Form ASP.NET mrideout BOOK: Beginning ASP.NET 1.0 4 July 19th, 2004 11:36 AM



All times are GMT -4. The time now is 05:36 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.