 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 11th, 2003, 03:26 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 12th, 2003, 12:05 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 13th, 2003, 02:26 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is there a way for me to capture the user's windows login via asp?
Renee C. Walker
|
|

November 14th, 2003, 02:41 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is there a way for me to capture the user's windows login via asp?
Renee C. Walker
|
|

November 14th, 2003, 04:01 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

November 18th, 2003, 11:46 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 18th, 2003, 01:29 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

November 18th, 2003, 02:33 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay, that's what I did. Let me check my code again.
Thanks for your help.
Renee C. Walker
|
|

December 13th, 2003, 04:41 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 20th, 2007, 03:27 PM
|
|
Registered User
|
|
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |