473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to get username ?

in vb its system.environment.username - whats the equivalent in aspx with
code behind (VB) ??

cheers

mark
Nov 18 '05 #1
4 3601
In the codebehind of your aspx code, you could use:

Page.User.Identity.Name ;

In a custom class, you could use:
HttpContext.Current.User.Identity.Name;

Hope this helps,

Kristof
"luna" <lu**@themoon.com> wrote in message
news:05**************@newsfep3-gui.server.ntli.net...
in vb its system.environment.username - whats the equivalent in aspx with
code behind (VB) ??

cheers

mark

Nov 18 '05 #2
thanks but niether seems to work - aspx accepts it but it does nothing!

thanks

mark
"Kristof Van Praet" <kr**************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
In the codebehind of your aspx code, you could use:

Page.User.Identity.Name ;

In a custom class, you could use:
HttpContext.Current.User.Identity.Name;

Hope this helps,

Kristof
"luna" <lu**@themoon.com> wrote in message
news:05**************@newsfep3-gui.server.ntli.net...
in vb its system.environment.username - whats the equivalent in aspx with code behind (VB) ??

cheers

mark


Nov 18 '05 #3
It depends how you would like to use it.

If you want to get the Windows username you have to make sure you disabled
anonymous access in IIS.

If you use forms authentication you can make a custom principal:
System.Security.Principal.GenericIdentity identity = new
System.Security.Principal.GenericIdentity("testUse rName");
System.Security.Principal.GenericPrincipal principal = new
System.Security.Principal.GenericPrincipal(identit y,new string[]{
"TestRole"});

Context.User = principal;

Hope this helps,

Kristof


"luna" <lu**@themoon.com> wrote in message
news:e2**************@newsfep3-gui.server.ntli.net...
thanks but niether seems to work - aspx accepts it but it does nothing!

thanks

mark
"Kristof Van Praet" <kr**************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
In the codebehind of your aspx code, you could use:

Page.User.Identity.Name ;

In a custom class, you could use:
HttpContext.Current.User.Identity.Name;

Hope this helps,

Kristof
"luna" <lu**@themoon.com> wrote in message
news:05**************@newsfep3-gui.server.ntli.net...
in vb its system.environment.username - whats the equivalent in aspx with code behind (VB) ??

cheers

mark



Nov 18 '05 #4
thats great!

works fine now
thanks!
mark
"Kristof Van Praet" <kr**************@hotmail.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
It depends how you would like to use it.

If you want to get the Windows username you have to make sure you disabled
anonymous access in IIS.

If you use forms authentication you can make a custom principal:
System.Security.Principal.GenericIdentity identity = new
System.Security.Principal.GenericIdentity("testUse rName");
System.Security.Principal.GenericPrincipal principal = new
System.Security.Principal.GenericPrincipal(identit y,new string[]{
"TestRole"});

Context.User = principal;

Hope this helps,

Kristof


"luna" <lu**@themoon.com> wrote in message
news:e2**************@newsfep3-gui.server.ntli.net...
thanks but niether seems to work - aspx accepts it but it does nothing!

thanks

mark
"Kristof Van Praet" <kr**************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
In the codebehind of your aspx code, you could use:

Page.User.Identity.Name ;

In a custom class, you could use:
HttpContext.Current.User.Identity.Name;

Hope this helps,

Kristof
"luna" <lu**@themoon.com> wrote in message
news:05**************@newsfep3-gui.server.ntli.net...
> in vb its system.environment.username - whats the equivalent in aspx

with
> code behind (VB) ??
>
> cheers
>
> mark
>
>



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Candice | last post by:
Please somebody help! I've deleted my admin username and password which was initially set at test. Now I can't log into my website as the administrator. How do I put Username and Password back so...
11
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are...
14
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the...
8
by: Philip Wagenaar | last post by:
I need to send printjobs to a printqueue under diffrent usernames. The printsoftware on the queue is not very 'secure' so I can create a user on 1 system and send a printjob under it's name to the...
0
by: Sid DeLuca | last post by:
I'm modifying the WSE2 HOL sample to develop my web service. I'm able to get the client application's username token encrypted on the way out (outputTrace.webinfo), but not on receipt from the...
5
by: libra786 | last post by:
I have created a blog and have added a login box which prompts the user for login and id before posting- The username and password have been stored in the database, however when i enter the username...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
4
nathj
by: nathj | last post by:
Hi, I'm working on a registration form and one of the checks I need to perform as the form is used is on the username. I need to ensure that it is not already in use. I am getting a little...
24
by: runway27 | last post by:
i have used the following code to validate the username it is working fineif( $username == "" || !preg_match("/^+(?:_+)?$/i", $username) ) { $error.="User name cannot be blank or has special...
2
by: shapper | last post by:
Hello, I know that only authenticated users has a UserName. In Anonymous users there is an ID. If I am not wrong when getting a profile of a user, if the user is authenticated the UserName is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.