Benutzer mit den meisten Antworten
C# aspx Usererkennung beim aufrufen der Seite

Frage
-
Hallo zusammen,
Ich habe eine kleine Seite gebastelt und ich möchte das sie den User erkennen welcher gerade auf der Seite ist, bzw den Computernamen oder seinen Windows Account Namen ausgibt.
mit
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); loggedInUserLabel.Text = stringname.ToString();
bekomme ich zwar local meinen Accountnamen, jedoch nicht wen es auf dem Server liegt. Dan erhalte ich die Meldung:
NT AUTHORITY\NETWORK SERVICEwas habe ich übersehen? Gibt es da irgendwelche Befehle?
Besten Dank
Gruss Wingfire
Antworten
-
Hallo W.
das hängt ein wenig von der Authentifizierungs-Art ab, die Du eingestellt hast.
Aber mit Impersonation hat das eigentlich nicht direkt etwas zu tun - damit könnte man die Identität eines anderen Users annehmen.
Normalerweise erkennt man den (Remote) User, der die Webseite gerade anschaut über:
HttpContext.Current.User.Identity.Name
oder Request.LogonUserIdentity.Name
Man kann ggf. auch die Request.ServerVariables dafür nutzen.
etwa: Request.ServerVariables["LOGON_USER"]; // siehe aber Link unten
Das, was Du benutzt hattes (WindowsIdentity.GetCurrent()) ist der Benutzer, der den aktuellen Prozess [auf dem Web-Server] ausführt.
[PRB: Request.ServerVariables("LOGON_USER") gibt leere Zeichenfolge in ASP.NET]
http://support.microsoft.com/kb/306359
Ich kopiere hier mal einen wichtigen Abschnitt daraus heraus:- ASP.NET provides new authentication modes and authorization schemes, which you can configure in the .config files. For this reason, modifying the authentication modes in IIS alone may not always yield the desired results. Therefore, you must also consider
the security settings in the .config files.
NOTE: When you enable Anonymous authentication in conjunction with Windows authentication or if you grant access to the Anonymous user in the <authorization> section while you are using any authentication mode other than None, other server variables such as AUTH_USER and REMOTE_USER (as well as the HttpContext.Current.User.Identity.Name property) also return an empty string. You can use the any of the above-mentioned resolutions to populate these variables.
ciao Frank- Als Antwort vorgeschlagen -Tim Afholderbach- Donnerstag, 24. Februar 2011 20:46
- Als Antwort markiert Robert BreitenhoferModerator Donnerstag, 3. März 2011 08:23
- ASP.NET provides new authentication modes and authorization schemes, which you can configure in the .config files. For this reason, modifying the authentication modes in IIS alone may not always yield the desired results. Therefore, you must also consider
the security settings in the .config files.
Alle Antworten
-
hi,
Ich habe eine kleine Seite gebastelt
hmpf, wir entwickeln, programmieren, designen, schmieden, craften, erzeugen, erstellen, produzieren Seiten, aber wir basteln nicht!)
und ich möchte das sie den User erkennen welcher gerade auf der Seite ist, bzw den Computernamen oder seinen Windows Account Namen ausgibt.
Siehe ASP.NET Impersonation, z.B.
http://msdn.microsoft.com/en-us/library/xh507fc5.aspx
Microsoft MVP Office Access
https://mvp.support.microsoft.com/profile/Stefan.Hoffmann -
Hallo W.
das hängt ein wenig von der Authentifizierungs-Art ab, die Du eingestellt hast.
Aber mit Impersonation hat das eigentlich nicht direkt etwas zu tun - damit könnte man die Identität eines anderen Users annehmen.
Normalerweise erkennt man den (Remote) User, der die Webseite gerade anschaut über:
HttpContext.Current.User.Identity.Name
oder Request.LogonUserIdentity.Name
Man kann ggf. auch die Request.ServerVariables dafür nutzen.
etwa: Request.ServerVariables["LOGON_USER"]; // siehe aber Link unten
Das, was Du benutzt hattes (WindowsIdentity.GetCurrent()) ist der Benutzer, der den aktuellen Prozess [auf dem Web-Server] ausführt.
[PRB: Request.ServerVariables("LOGON_USER") gibt leere Zeichenfolge in ASP.NET]
http://support.microsoft.com/kb/306359
Ich kopiere hier mal einen wichtigen Abschnitt daraus heraus:- ASP.NET provides new authentication modes and authorization schemes, which you can configure in the .config files. For this reason, modifying the authentication modes in IIS alone may not always yield the desired results. Therefore, you must also consider
the security settings in the .config files.
NOTE: When you enable Anonymous authentication in conjunction with Windows authentication or if you grant access to the Anonymous user in the <authorization> section while you are using any authentication mode other than None, other server variables such as AUTH_USER and REMOTE_USER (as well as the HttpContext.Current.User.Identity.Name property) also return an empty string. You can use the any of the above-mentioned resolutions to populate these variables.
ciao Frank- Als Antwort vorgeschlagen -Tim Afholderbach- Donnerstag, 24. Februar 2011 20:46
- Als Antwort markiert Robert BreitenhoferModerator Donnerstag, 3. März 2011 08:23
- ASP.NET provides new authentication modes and authorization schemes, which you can configure in the .config files. For this reason, modifying the authentication modes in IIS alone may not always yield the desired results. Therefore, you must also consider
the security settings in the .config files.