Ask a Question related to ASP.NET Security, Design and Development.
-
User.Identity.Name returns nothing / NULL
Hi
I have created two pages, the login.aspx and the formA.aspx, and each of
this has a corresponding *.cs files for code separation
the scenario is, I seems to be able to login / authenticated because
formA.aspx got loaded. But when I added the following lines
Label1.Text = HttpContext.Current.User.Identity.Name;
to the Page_Load event under FormA.cs, the control Label1 simply not showing
anything!
Do I need to do anything to get the "User.Identity.Name" set? (in config
files and / or after successful login)?
What is the problem here, please?
TIA
____
username and password collected by login.aspx is authenticated against the
AD with LDAP using the following code
//
DirectoryEntry entry = new DirectoryEntry(strPath, uName, pwd);
try
{
// Bind to the native object to force authentication to happen
Object obj = entry.NativeObject;
}
catch (Exception ex)
{
throw new Exception("User authentication failed: " +
ex.Message);
}
Server.Transfer("formA.aspx");
_______
formA.aspx contains a form for user to fill out some information.
--
Guest
-
ASP.NET User.Identity.Name returns wrong value?
When I got Visual Studio setup and configured to remotely debug c# ASP.NET applications on a development IIS server I apparently changed something... -
#26132 [Bgs]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 User updated by: steven at pearavenue dot com Reported By: steven at pearavenue dot com Status: Bogus Bug... -
#26132 [Opn->Bgs]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 Updated by: iliaa@php.net Reported By: steven at pearavenue dot com -Status: Open +Status: ... -
#26132 [Opn]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
ID: 26132 User updated by: steven at pearavenue dot com Reported By: steven at pearavenue dot com Status: Open Bug... -
#26132 [NEW]: pg_fetch_object returns NULL on serial and INT in record but returns strings NP
From: steven at pearavenue dot com Operating system: Redhat 9.0/Apache 2.0 PHP version: 4.3.4 PHP Bug Type: PostgreSQL... -
Dominick Baier [DevelopMentor] #2
Re: User.Identity.Name returns nothing / NULL
Hello dl,
makes sure you are really authenticated - IIS is LBD (lazy by default). Go
the the directory security tab and clear "anonymous login" for the virtual
directory.
---------------------------------------
Dominick Baier - DevelopMentor
[url]http://www.leastprivilege.com[/url]
> Hi
> I have created two pages, the login.aspx and the formA.aspx, and each
> of
> this has a corresponding *.cs files for code separation
> the scenario is, I seems to be able to login / authenticated because
> formA.aspx got loaded. But when I added the following lines
> Label1.Text = HttpContext.Current.User.Identity.Name;
> to the Page_Load event under FormA.cs, the control Label1 simply not
> showing anything!
>
> Do I need to do anything to get the "User.Identity.Name" set? (in
> config
> files and / or after successful login)?
> What is the problem here, please?
> TIA
> ____
> username and password collected by login.aspx is authenticated against
> the
> AD with LDAP using the following code
> //
> DirectoryEntry entry = new DirectoryEntry(strPath, uName,
> pwd);
> try
> {
> // Bind to the native object to force authentication to
> happen
> Object obj = entry.NativeObject;
> }
> catch (Exception ex)
> {
> throw new Exception("User authentication failed: " +
> ex.Message);
> }
> Server.Transfer("formA.aspx");
> _______
> formA.aspx contains a form for user to fill out some information.
Dominick Baier [DevelopMentor] Guest
-
Dominick Baier [DevelopMentor] #3
Re: User.Identity.Name returns nothing / NULL
Hello dl,
ah - ok - if you are doing custom authentication - you have to construct
an IPrincipal object yourself -
have a look at GenericPrincipal and AuthenticateRequest in the docs.
Basically you have to construct that Principal object in the AuthenticateRequest
event and attach it to Context.User, like
Context.User = new GenericPrincipal(new GenericIdentity(..), roles);
---------------------------------------
Dominick Baier - DevelopMentor
[url]http://www.leastprivilege.com[/url]
> Hi
> I have created two pages, the login.aspx and the formA.aspx, and each
> of
> this has a corresponding *.cs files for code separation
> the scenario is, I seems to be able to login / authenticated because
> formA.aspx got loaded. But when I added the following lines
> Label1.Text = HttpContext.Current.User.Identity.Name;
> to the Page_Load event under FormA.cs, the control Label1 simply not
> showing anything!
>
> Do I need to do anything to get the "User.Identity.Name" set? (in
> config
> files and / or after successful login)?
> What is the problem here, please?
> TIA
> ____
> username and password collected by login.aspx is authenticated against
> the
> AD with LDAP using the following code
> //
> DirectoryEntry entry = new DirectoryEntry(strPath, uName,
> pwd);
> try
> {
> // Bind to the native object to force authentication to
> happen
> Object obj = entry.NativeObject;
> }
> catch (Exception ex)
> {
> throw new Exception("User authentication failed: " +
> ex.Message);
> }
> Server.Transfer("formA.aspx");
> _______
> formA.aspx contains a form for user to fill out some information.
Dominick Baier [DevelopMentor] Guest
-
Re: User.Identity.Name returns nothing / NULL
Hi Dominick
I think this is the problem, and I found the following link under MS
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/active_directory_authentication_from_ASP__Net.asp[/url]
has an example using code behind with VS.Net, the problem is I am only using
Web Matrix / VWD 2005 Express. I am trying to put the Global.asax code in a
class using <@page ... inherits=...>, but there is one line I am having
problem with, can you help, please?
HttpCookie authCookie = Context.Request.Cookies[cookieName];
on compiling the class, I am getting the following error
The type or namespace "Context" could not be found (are you missing a using
directive or an assembly reference?)
by the way, can you give me the link to the docs on AuthenticateRequest /
GenericPricipal?
Is there any other good example on Form authentication along with the
required Global.asax file?
TIA
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
wrote in message news:364328632512174720446016@news.microsoft.com.. .AuthenticateRequest> Hello dl,
>
> ah - ok - if you are doing custom authentication - you have to construct
> an IPrincipal object yourself -
>
> have a look at GenericPrincipal and AuthenticateRequest in the docs.
>
> Basically you have to construct that Principal object in the> event and attach it to Context.User, like
>
> Context.User = new GenericPrincipal(new GenericIdentity(..), roles);
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> [url]http://www.leastprivilege.com[/url]
>>> > Hi
> > I have created two pages, the login.aspx and the formA.aspx, and each
> > of
> > this has a corresponding *.cs files for code separation
> > the scenario is, I seems to be able to login / authenticated because
> > formA.aspx got loaded. But when I added the following lines
> > Label1.Text = HttpContext.Current.User.Identity.Name;
> > to the Page_Load event under FormA.cs, the control Label1 simply not
> > showing anything!
> >
> > Do I need to do anything to get the "User.Identity.Name" set? (in
> > config
> > files and / or after successful login)?
> > What is the problem here, please?
> > TIA
> > ____
> > username and password collected by login.aspx is authenticated against
> > the
> > AD with LDAP using the following code
> > //
> > DirectoryEntry entry = new DirectoryEntry(strPath, uName,
> > pwd);
> > try
> > {
> > // Bind to the native object to force authentication to
> > happen
> > Object obj = entry.NativeObject;
> > }
> > catch (Exception ex)
> > {
> > throw new Exception("User authentication failed: " +
> > ex.Message);
> > }
> > Server.Transfer("formA.aspx");
> > _______
> > formA.aspx contains a form for user to fill out some information.
>
>
Guest
-
Dominick Baier [DevelopMentor] #5
Re: User.Identity.Name returns nothing / NULL
Hello dl,
there is a sample on my blog which shows you how do this:
[url]http://www.leastprivilege.com/PermaLink.aspx?guid=b0e51388-71d1-4a6f-98d0-bc8cfbec4c3a[/url]
btw - you can always get a context by calling:
HttpContext context = HttpContext.Current;
feel free to ask if you have any questions
HTH
---------------------------------------
Dominick Baier - DevelopMentor
[url]http://www.leastprivilege.com[/url]
> Hi Dominick
>
> I think this is the problem, and I found the following link under MS
>
> [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/s[/url]
> ds/active_directory_authentication_from_ASP__Net.asp
>
> has an example using code behind with VS.Net, the problem is I am only
> using
>
> Web Matrix / VWD 2005 Express. I am trying to put the Global.asax
> code in a
>
> class using <@page ... inherits=...>, but there is one line I am
> having
>
> problem with, can you help, please?
>
> HttpCookie authCookie = Context.Request.Cookies[cookieName];
>
> on compiling the class, I am getting the following error
> The type or namespace "Context" could not be found (are you missing a
> using
> directive or an assembly reference?)
> by the way, can you give me the link to the docs on
> AuthenticateRequest /
> GenericPricipal?
> Is there any other good example on Form authentication along with the
> required Global.asax file?
> TIA
>
> "Dominick Baier [DevelopMentor]"
> <dbaier@pleasepleasenospamdevelop.com> wrote in message
> news:364328632512174720446016@news.microsoft.com.. .
>> AuthenticateRequest>> Hello dl,
>>
>> ah - ok - if you are doing custom authentication - you have to
>> construct an IPrincipal object yourself -
>>
>> have a look at GenericPrincipal and AuthenticateRequest in the docs.
>>
>> Basically you have to construct that Principal object in the
>>
>>> event and attach it to Context.User, like
>>
>> Context.User = new GenericPrincipal(new GenericIdentity(..), roles);
>>
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> [url]http://www.leastprivilege.com[/url]>>> Hi
>>> I have created two pages, the login.aspx and the formA.aspx, and
>>> each
>>> of
>>> this has a corresponding *.cs files for code separation
>>> the scenario is, I seems to be able to login / authenticated because
>>> formA.aspx got loaded. But when I added the following lines
>>> Label1.Text = HttpContext.Current.User.Identity.Name;
>>> to the Page_Load event under FormA.cs, the control Label1 simply not
>>> showing anything!
>>> Do I need to do anything to get the "User.Identity.Name" set? (in
>>> config
>>> files and / or after successful login)?
>>> What is the problem here, please?
>>> TIA
>>> ____
>>> username and password collected by login.aspx is authenticated
>>> against
>>> the
>>> AD with LDAP using the following code
>>> //
>>> DirectoryEntry entry = new DirectoryEntry(strPath, uName,
>>> pwd);
>>> try
>>> {
>>> // Bind to the native object to force authentication to
>>> happen
>>> Object obj = entry.NativeObject;
>>> }
>>> catch (Exception ex)
>>> {
>>> throw new Exception("User authentication failed: " +
>>> ex.Message);
>>> }
>>> Server.Transfer("formA.aspx");
>>> _______
>>> formA.aspx contains a form for user to fill out some information.
Dominick Baier [DevelopMentor] Guest
-
Re: User.Identity.Name returns nothing / NULL
Hi Dominick
Thankyou very much.
In fact, I just experience a problem with the formA.aspx / formA.cs and post
another thread on newsgroup microsoft.public.dotnet.framework.aspnet, wonder
if you spare some time to take a look and advice on that also ?!
TIA
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
wrote in message news:366402632512610278910960@news.microsoft.com.. .[url]http://www.leastprivilege.com/PermaLink.aspx?guid=b0e51388-71d1-4a6f-98d0-bc8cfbec4c3a[/url]> Hello dl,
>
> there is a sample on my blog which shows you how do this:
>>
> btw - you can always get a context by calling:
>
> HttpContext context = HttpContext.Current;
>
> feel free to ask if you have any questions
>
> HTH
> ---------------------------------------
> Dominick Baier - DevelopMentor
> [url]http://www.leastprivilege.com[/url]
>>> > Hi Dominick
> >
> > I think this is the problem, and I found the following link under MS
> >
> > [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/s[/url]
> > ds/active_directory_authentication_from_ASP__Net.asp
> >
> > has an example using code behind with VS.Net, the problem is I am only
> > using
> >
> > Web Matrix / VWD 2005 Express. I am trying to put the Global.asax
> > code in a
> >
> > class using <@page ... inherits=...>, but there is one line I am
> > having
> >
> > problem with, can you help, please?
> >
> > HttpCookie authCookie = Context.Request.Cookies[cookieName];
> >
> > on compiling the class, I am getting the following error
> > The type or namespace "Context" could not be found (are you missing a
> > using
> > directive or an assembly reference?)
> > by the way, can you give me the link to the docs on
> > AuthenticateRequest /
> > GenericPricipal?
> > Is there any other good example on Form authentication along with the
> > required Global.asax file?
> > TIA
> >
> > "Dominick Baier [DevelopMentor]"
> > <dbaier@pleasepleasenospamdevelop.com> wrote in message
> > news:364328632512174720446016@news.microsoft.com.. .
> >> > AuthenticateRequest> >> Hello dl,
> >>
> >> ah - ok - if you are doing custom authentication - you have to
> >> construct an IPrincipal object yourself -
> >>
> >> have a look at GenericPrincipal and AuthenticateRequest in the docs.
> >>
> >> Basically you have to construct that Principal object in the
> >>
> >> >> event and attach it to Context.User, like
> >>
> >> Context.User = new GenericPrincipal(new GenericIdentity(..), roles);
> >>
> >> ---------------------------------------
> >> Dominick Baier - DevelopMentor
> >> [url]http://www.leastprivilege.com[/url]
> >>> Hi
> >>> I have created two pages, the login.aspx and the formA.aspx, and
> >>> each
> >>> of
> >>> this has a corresponding *.cs files for code separation
> >>> the scenario is, I seems to be able to login / authenticated because
> >>> formA.aspx got loaded. But when I added the following lines
> >>> Label1.Text = HttpContext.Current.User.Identity.Name;
> >>> to the Page_Load event under FormA.cs, the control Label1 simply not
> >>> showing anything!
> >>> Do I need to do anything to get the "User.Identity.Name" set? (in
> >>> config
> >>> files and / or after successful login)?
> >>> What is the problem here, please?
> >>> TIA
> >>> ____
> >>> username and password collected by login.aspx is authenticated
> >>> against
> >>> the
> >>> AD with LDAP using the following code
> >>> //
> >>> DirectoryEntry entry = new DirectoryEntry(strPath, uName,
> >>> pwd);
> >>> try
> >>> {
> >>> // Bind to the native object to force authentication to
> >>> happen
> >>> Object obj = entry.NativeObject;
> >>> }
> >>> catch (Exception ex)
> >>> {
> >>> throw new Exception("User authentication failed: " +
> >>> ex.Message);
> >>> }
> >>> Server.Transfer("formA.aspx");
> >>> _______
> >>> formA.aspx contains a form for user to fill out some information.
>
>
Guest



Reply With Quote

