Getting the user name of the currently logged in user

I'm writing my first custom module. Just as an experimental project I would just display information about the currently logged in user.

I can get the User Id, but I don't know where to get the rest of the information. How do I get this?
0
ColinAngusMackay
9/29/2004 12:36:15 PM
asp.net.dotnetnuke 25171 articles. 0 followers. Follow

2 Replies
1316 Views

Similar Articles

[PageSpeed] 4

Hi, 

Just create a new UserController to get the information about one user via the method GetUser(PortalId, UserId) and store it into a UserInfo. Then you can get the rest of the information from this UserInfo
[VB]
Dim myUser As New UserInfo
Dim myUserController As New UserController
myUser = myUserController.GetUser(PortalId, UserId)
' And then for instance '
Dim myUserName As String = myUser.UserName
Dim myUserEmail As String = myUser.Email
' and so on ... '
Eddy Hung Sik Yan

NETMedia presents: nukedArea

www.netmedia.hr
0
nunchaks
9/29/2004 1:03:13 PM
Hi,

Many thanks, that worked - I'm using C# (I should have said, but I can read VB.NET anyway) so my code looks like this:

private void Page_Load(object sender, System.EventArgs e)
{
UserController theUserController = new UserController();
UserInfo theUser = theUserController.GetUser(PortalId, UserId);
UserIdLabel.Text = this.UserId.ToString();
UserNameLabel.Text = theUser.Username;
}
Regards,
Colin.
0
ColinAngusMackay
9/29/2004 1:29:42 PM
Reply:

Similar Artilces:

Can not get user name from HttpContext.Current.User.Identity.Name
Hi All; I have tried to use HttpContext.Current.User.Identity.Name to get window user account. However, from debugger, for a long time ago I saw my window user name. But now, I did not see my window user name (from debugger) with the same code and same function call. Please help. Was I doing something wrong? Or any special settings on web.config/machine.config or project to make it work??? I'm stuck Thanks a lot well, you have to have windows integrated authentiction enabled in IIS, IIRC.RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unre...

how to get the user id of the currently logged in user?
hi,       m develoing a site whereby employees are supposed to log in and take orders.  the users are being created thru the ASP web Administration tool and stored by default into the SQL Server Database named AspNetDB.mdf that's stored in the App_Data folder of our website. the database is created auomatically. How to display the userid as this userid is too complicated and there can be many users with the same username. You can use the Membership class to get the info about a user: Membership.GetUser() The GetUser method can also take a username as a...

Problem in getting logged in user Name for ASPX page with (even with this.User.Identity.Name)
Hi  friends,  I am creating an application that takes current logged in user and displays on the page itself. for this I am getting the user name in PageLoad function by using this.User.Identity.Name and then storing the value in a hidden variable for aspx page. I am using this hidden  variable to display the name of the user. I am using Windows authentication for this. Now problem that I am getting is that when multiple user launch the application from different machine and if they click simultaneously, name of one user appears on the paged displayed on the machine of ot...

how to get the user group name by HttpContext.Current.User?
Is it possible to get the domain user group name or role name on domain server by HttpContext.Current.User?For example, I want to identify if the user belongs to group myDomain/Administrators, I try to use User.IsInRole("myDomain/Administrators"), but I failed.One user maybe join multiple groups. How to get the all groups in code for current user?  Demo code for C# and VB please.   Try using this instead: VB: If Page.User.IsInRole("DOMAIN\GROUPNAME") C# If Page.User.IsInRole("DOMAIN\\GROUPNAME") Note, this will only work if you have ...

How can i get the user id of the user currently logged in?
Hi, I need to get the userId of the user currently logged in. Do I need to use 'user profile' for that? I am using the database schemas installed by the aspnet_regsql.exe. Any suggestions will be very much appreciated. E     Dim user As MembershipUser        user = Membership.GetUser(True)        Label1.Text = user.UserName If this post was useful to you, please mark it as answer. Thank you!Regards.mimranshafiq.NET Web Developerhttp://www.dotnetclassic.com VB:Dim usr as MembershipUser=Membership....

Application User and still getting the logged in User Name
Hi I have a very intranet situation where User opens the Web Page Now here is calls a Database table where User Rights are stored But access to this database table is given to dbo and Application Uer which is created in IIS Server folder by clicking on Allow Anomymous Login=true when I try to run the Table Query and pass the USer Name I get null UserName how to deal with this situation   Thanks       so do you have anonymous access ON? try deny anonymous access to your application. Enable impersonation in your web.config./GuruBhai Hi, By default, ASP.N...

How do i get the Name of currently logged in user
 i know there is LOGINNAME control to get the name of currently logged in user.. but i want to Display that name in Label Control... is there any Method to get the Name of currently logged in user from LOGINNAME ??[ :O] thanx in Advance   Label1.Text = Page.User.Identity.Name;TalhaMCP, MCADPersonal Site thank u so much ...

Session problem(Previous Users log-in details are getting displayed/withheld for the current user)
Hi we've hosted Bugzilla in windows 2000 server & it has been used by many users at a given time.we've been getting this peculiar Session problem.ie.If a user logs-in, the page that he visits contains the details of another user who has just signed out from bugzilla.Any & all suggestions are welcome. Regards Tamil ...

getting the current user name that's logged in through the vpn.
I have a question. I was wonder is it possible to get the username of the person that is logged in through the vpn? right now the client uses cisco client to connect to our network. after they are connected the user connects to our citrix server where they input the user name and password for the network. now then if they go to my website it prompts them again for there user credaintals. I do not want this. I have IIS setup to not allow anonymous access to the page. my web.config file is set to windows authentication. sounds like a security issue, I'd re-post to the security for...

get dotnetnuke current user login name to app in IFrame
I have an application that I would like to use in an iFrame. I currently use the windows authnetication to get the User.Identity.Name, but would like to use the dotnetnuke security login. Is there any way for me to pass the dotnetnuke security username to a aspx page in an IFrame so then I can do a query against that username. thanks for any ideas. figured it out. thanks. this can be deleted MagicGadget will do this Pass it as a querystring parameter to the IFrame. Otherwise you need more fancy solutions and I can't help with those :( At least that's the only way I know.-Sean...

How to get windows log-in user name using vb.net code?
Hi, I built an asp.net web application on our companies HR system so that recruitors can post jobs. Is there a way to get the windows logged in user name using vb.net code? This user name is using for tracking who posted the job. Thank you.   Windows Authentication provides some options, as does forms authentication.  See if you get what you need through User.Identity.Name.  Take a look at: http://www.15seconds.com/issue/020220.htmhttp://aspnet.4guysfromrolla.com/articles/120705-1.aspx JeffPlease: Don't forget to click "Mark as Answer" on the p...

difference between HttpContext.Current.User.Identity.Name and User.Identity.Name
Q1. what is the difference between 1. HttpContext.Current.User.Identity.Name;and 2. User.Identity.Name Q2.i'm using asp.net 2.0. i'm using the following code to authenticate FormsAuthentication.RedirectFromLoginPage(strEMail, false); Response.Redirect("web/ra.aspx"); my main web.config has <authentication mode="Forms">      <forms          name=".ASPXAUTH"          loginUrl="back.htm"          protection="All" &n...

Get the User Name for a login user
Hi Guys, How can I get the current loged in UserName in windows in MSSQL? The problem is: Users login into their PC (Windows Login) Enter a URL of the intranet application They would then be able to access the web base application (Intranet) The web application has a string connection to make a connection to the database I want to have a Trigger for my "products" table so if the table is modified (Insert/Update)  all those changes be entered in "products_Audit" table Now on "products_Audit" table I have a field "ChangedBy" where I want to store the windows loged...

get user name by user id
hi i send the user ID to a page and there i wanna find the user name. can you please let me know how to find a user name by user id? tanks  Are you using Active Directory? If so check out this tutorialCommunity Coder Hi you can pass the Guid USerId to Membership.GetUser method,MembershipUser usr = Membership.GetUser(UserIDAsGuid); string userName = usr.UserName; // to get the current logged in username , just use HttpContext.Current.User.Identity.Name;    Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed som...

Web resources about - Getting the user name of the currently logged in user - asp.net.dotnetnuke

’12 Days Of Christmas’: Hallmark Personal Shopper Movie Stars Katrina Law, Donna Mills, And Aaron O’Connell ...
12 Gifts of Christmas is the newest comedy romance movie that will premiere on the Hallmark Channel on Thanksgiving Day. In fulfillment of its ...

Full Episode: WN 11/25/15: President Obama Pardons Two Lucky Turkeys
Winter storm impairs Thanksgiving travel;US heightens security as millions travel for holiday.

Navigator of Downed Russian Plane Says There Was No Warning
New York Times Navigator of Downed Russian Plane Says There Was No Warning New York Times MOSCOW — The Russian navigator who parachuted out ...

Thanksgiving Movies and Marathons
You’re off work for Thanksgiving, and you’ve watched the parade, maybe the Westminster Dog Show, and you’re not really into football. What to ...

2015 likely to be warmest on record, 2011-2015 warmest five year period
The global average surface temperature in 2015 is likely to be the warmest on record and to reach the symbolic and significant milestone of 1° ...

DAILY MAIL COMMENT: George Osborne's Autumn Statement was a huge gamble
George Osborne showed himself a master of his political trade in yesterday's Autumn Statement - but seems to have abandoned his early enthusiasm ...

Watch: Eagles of Death Metal Give First Interview Since Paris Attacks
Two weeks after ISIS militants besieged the Nov. 13 concert of rock band Eagles of Death Metal, the group has opened up for the first time about ...

Human error led to deadly US strike on Afghan hospital -military
Reuters Human error led to deadly US strike on Afghan hospital -military Reuters WASHINGTON A U.S. investigation found that the deadly Oct. ...

Exclusive: U.S. has urged legal reforms abroad to block Islamic State recruits
By Mark Hosenball WASHINGTON (Reuters) - The U.S. Justice Department has provided specific suggestions to governments in Europe and elsewhere ...

Donald Trump To Receive Endorsement From 100 African-American Pastors
Donald Trump is expected to be endorsed for president by 100 African-American pastors and faith-based leaders in a press conference scheduled ...

Resources last updated: 11/26/2015 6:01:29 AM