Last post Jun 15, 2015 02:54 PM by ClaudioNastasiJunior
Jun 09, 2015 04:16 PM|ClaudioNastasiJunior|LINK
I am trying to use the Request.ServerVariables["LOGON_USER"] method in C#, and the problem is: I'm using this method
in one page, let's call it the page A, and in the page A this method is working just fine, but in another page, the page B, that is on the same server of the page A, this method isn't working, it returns empty. I have already added the authentication tag in
web.config and it steel not working. Does anyone know what I'm doing wrong or what i'm missing?
Jun 10, 2015 04:14 AM|Ashim Chatterjee|LINK
The LOGON_USER variable will not be populated if you use the Allow Anonymous security to access the page,so make sure you disable this. In order for the LOGON_USER variable to be populated, the user must be authenticated using either Basic
or NT Challenge/Response security.
Jun 10, 2015 03:13 PM|ClaudioNastasiJunior|LINK
I understand, but for example: there are two applications in the same server, that are using the same IIS. I need to configure this in the web.config of the application or in the configuration of the IIS?
I've tried to put this code into the web.config:
<authentication mode="Forms" />
<!-- To deny access to the Anonymous user in the Web.config file, use the following syntax: --!>
<deny users = "?" /> <!-- This denies access to the Anonymous/unregistered user -->
<allow users ="*" /> <!-- This allows access to all registered users -->
Well, it didn't worked. It's a kind of credential error or something...
So, how could I do it?
Jun 10, 2015 11:30 PM|Ashim Chatterjee|LINK
there are two applications in the same server, that are using the same IIS.
Both applications share same application pool or different ? If Logon_User is giving u empty then try putting both the applications under same app pool and use context.User.Identity.Name instead of
Jun 11, 2015 09:05 PM|Nan Yu|LINK
Thanks for your post.
According to your description, I suggest that you could use User.Identity.Name or by using WindowsIdentity.GetCurrent().Name as follows :
string login = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Request.ServerVariables("LOGON_USER") has been depreciated for C#.
For more information , please refer to links below:
Jun 15, 2015 02:54 PM|ClaudioNastasiJunior|LINK
Ok, I got it.