client login name

  • Thread starter Thread starter catweezle2010
  • Start date Start date
C

catweezle2010

Hello,

I have to identify the user of an asp.net site by his windows login
name (like environment.currentuser in Access). Till a few days I'm
trying several scripts I've found. For example one like this:
strLogonName =
System.Security.Principal.WindowsIdentity.GetCurrent().Name

The best result was to display the asp-account on the Server. But I
need the username on the client.

We are working in a windows2k environment with iis 6 and asp.net 1.1.

Thanks for help!
 
Give HttpContext.User.Identity.Name a try...pretty sure that's what
you're looking for.
 
catweezle2010 said:
Hello,

I have to identify the user of an asp.net site by his windows login
name (like environment.currentuser in Access). Till a few days I'm
trying several scripts I've found. For example one like this:
strLogonName =
System.Security.Principal.WindowsIdentity.GetCurrent().Name

The best result was to display the asp-account on the Server. But I
need the username on the client.

We are working in a windows2k environment with iis 6 and asp.net 1.1.

Thanks for help!

If your site allows anonymous access (in IIS !), then you will never get
a login-name. So clear that checkbox.
Then you can use
this.Page.User as WindowsPrincipal
to get at the login data.

Hans Kesting
 
Thanks - now have an error which I had not before:
Compiler Error Message: BC30469: Reference to a non-shared member
requires an object reference.
The code: strLogonName = HttpContext.User.Identity.Name
 
In your scenario, you can

1) Set Windows authentication:
in Web.Config file
<authentication mode="Windows"/>

2) Deny anonymous access
in Web.Config file
<authorization>
<deny users="?" /> <!-- Deny anonymous users -->
<allow users="*"/> <!-- Allow all other users -->
</authorization>

3) Then use
User.Identity.Name
to get Domain_Name\User_Win_Login_ID

HTH

Elton Wang
(e-mail address removed)
 
Thanks to all, a long search is ending here.

@Elton W: I allready used user.identity.name but failed.

My settings in IIS an web.config were right, but it seems they do not
work without the <autorization> part in web.config.

So thanks a lot. Maybe you can help me in my next post (loosing session
value).
 
catweezle2010 said:
Thanks - now have an error which I had not before:
Compiler Error Message: BC30469: Reference to a non-shared member
requires an object reference.
The code: strLogonName = HttpContext.User.Identity.Name

add a "Current" inbetween:
HttpContext.Current.User.Identity.Name

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top