API TO get User Name

What is an Win32 call to get the user name in the form of COMPUTER\\User ? 


0
4/27/2007 9:58:59 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
874 Views

Similar Articles

[PageSpeed] 32

>What is an Win32 call to get the user name in the form of COMPUTER\\User ? 

Have a look at GetUserNameEx NameSamCompatible 

Dave
0
davidl7375 (2060)
4/28/2007 1:21:36 AM
Hi Michael,

Yes, just as David provided, GetUserNameEx will help you to retrieve the 
user or other security principal associated with the calling thread. 

If you got a different token other than the current calling thread, you may 
first call ImpersonateLoggedOnUser by passing the token to impersonate the 
token in the current thread and then use GetUserNameEx to obtain the user 
name associated the token. 

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


0
jetan (40)
4/30/2007 5:56:19 AM
I'm not sure what you mean by 'a different token'


""Jeffrey Tan[MSFT]"" <jetan@online.microsoft.com> wrote in message 
news:Uio0UxuiHHA.5016@TK2MSFTNGHUB02.phx.gbl...
> Hi Michael,
>
> Yes, just as David provided, GetUserNameEx will help you to retrieve the
> user or other security principal associated with the calling thread.
>
> If you got a different token other than the current calling thread, you 
> may
> first call ImpersonateLoggedOnUser by passing the token to impersonate the
> token in the current thread and then use GetUserNameEx to obtain the user
> name associated the token.
>
> Hope it helps.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no 
> rights.
>
> 


0
5/2/2007 3:31:29 AM
Hi Michael,

Thank you for the feedback.

Normally, a process is associated with a token to express his security 
context information. All the threads in the process will use the process 
token. However, there is a scenario that some other process have called 
LogonUser or some other APIs to created a token for its own purpose, and 
they may pass this created token to your application. In this scenario, if 
your process wanted to get the username in this token instead of the 
default security token associated with current process, a tricky way is 
first impersonating this token in the current thread, and then call 
GetUserNameEx. Since the impersonation will associate the token with 
current thread, GetUserNameEx will not look the default process token but 
the thread associated token to get user name. 

Anyway, if your application does not need this requirement, you may simple 
call GetUserNameEx to get the process token user name. 

Hope this is clear. 

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


0
jetan (40)
5/2/2007 4:57:59 AM
Reply:

Similar Artilces:

Can't get email via owa address anymore
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange I'm a bit of a novice with Entourage so apologise in advance. <br><br>I work from home for my company and have an email address on an exchange server. <br><br>I used to enter the OWA address into Office 2004 and my email/cal/contacts would download with no problems. <br><br>I'm a bit stumped with Entourage 2008 - it shows my work account as 'connected' but nothing downloads. I've verified that all my details in the account set up ar...

Show Series Name
Hi I have a line graph showing 24 months of data. As the colours begin to repeat themselves it is difficult to tell which series is which. I would just like to have, on the chart next to each series something showing the series name. I am using Excel 2007 and the option to show series on the more data labels option shows series name on every data point. given that I have over 30 data points and 24 series the chart looks messy. is there a simple waty to show series name next to each line/ Thankyou Rup “I would just like to have, on the chart next to each series something s...

Importing Named Ranges in MS Query
I want to use multiple ranges (named) as the data source for a pivot table using MS Query. When I import the workbook my options are only to select the "tables" (which are my sheets referenced as sheetname$). I don't want to use the entire sheet, just my named ranges in multiple sheets. Please help. Kathy H ...

Outlook Appointments off by 1 Hour on some Users Outlook Calendar
I have some users that have SOME appointments (both recurring and single instance) that are off by 1 hour. I have tried the Outlook Time Zone Move program on 3 separate computers (all runing Win XP Pro/Outlook 2007) and the program "finds no appointments that need fixing"...but there are clearly one or more that need fixed if I manually look in their calendar. The weird thing is that when I run the tool on my Outlook (Windows 7 Ult/Outlook 2007) it still shows no appointments need fixing but it gives me a "details" button to show my appointments where I can ...

File name problems
I am using Microsoft Office 97 on Windows XP and I am encountering a problem when saving a file. No matter how you type the filename, it only saves to the first letter of the filename (example home becomes h) Any way around this problem? Check to see if Excel is running in Windows 95 compatibility mode. There was a post that said: When I disabled compatibility mode the file name problem went away. http://google.com/groups?threadm=020101c30916%2442320250%24a501280a%40phx.gbl And maybe this will help: HOW TO: Use Windows Program Compatibility Mode in Windows XP http://support.microsoft....

graphics getting lost under background color
Hi I have black background color for my view BOOL CMyView::OnEraseBkgnd(CDC* pDC) { CRect rect; pDC->GetClipBox(&rect); pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), BLACKNESS); return 1; } I draw some lines in void CMyView::OnDraw(CDC* pDC) { ... ... } I take my application in the background and again bring it in front. But all the graphics is lost. Why is that so.. To my knowledge OnEraseBkgnd is called first and then OnPaint that is OnDraw handler then why is that happening. Thanks Lee On 4 Apr 2006 00:29:56 -0700, "yang__lee@ausi.com" <yang_...

How to get user name which is active in windows
I am working a software which can set specific conf. for each user, so my program needs to know which user is active now, which API or MFC class can do it? -- Nothing impossible, Nothing sure GetUserName/GetUserNameEx --- Ajay I do it like this: // This function is useful for retrieving the current user name BOOL GetUser(CString &csUser) { TCHAR szUserName[80]; DWORD dwResult, cchBuff = 80; // Call the WNetGetUser function. dwResult = WNetGetUser(NULL, (LPTSTR) szUserName, &cchBuff); if(dwResult != NO_ERROR) return false; csUser = szUserName; ...

Save sheet copy with cell value name using a macro.
Good afternoon All, I need a VB statement to save a copy of the sheet i'm using (same were the macro is executed) with a cell value (EG cell "B2") of the workbook I'm using into a predefined path (EG "C:\"). If anybody can help me with this I'll be very glad. Leo. You want to save a sheet as a workbook with a name of the value in Range("B2") of the sheet? Sub Make_New_Book() Dim w As Worksheet Application.ScreenUpdating = False Application.DisplayAlerts = False ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:="C:\...

Display Parent Name and Address on Invoice
I have not been unable to add the Parent name or address to the Invoice document in RW. My workaround is to add the Parent information as the Child's Bill to address but this means the user must perform this additional data entry for each new child customer. Has anyone been able to workaround this? Thanks, Lea Lea, You will most likely need to add this information with a bit of VBA and ADO as there is no way to build a circular reference to a table in Report Writer. Please take a look at the following articles for the techniques to add this information: Using ADO with VBA with RW...

alias Money 2004 db to multiple XP users?
I'm running Money 2004 on XP (home) and Money can only find the Money database in the directory structure associated with the user who loaded Money on the machine. Is there a recommended way of pointing Money, invoked by another user on the same machine, to the directory structure that contains the Money db? thanks. Place the fle in a shared folder maybe? Or move it to your profile? Then click on it to run money and should eb ok I would think. "rc phelps" <greentruck1970@hotmail.com> wrote in message news:1f2b701c457f0$2abe0400$a601280a@phx.gbl... > > I'...

How can I get the handles for a picture frame in Publisher?
Whenever I try to make a picture frame, I get an insert picture menu box instead of the frame itself. Upon clicking cancel, the entire box, menu, is deleted and I cannot get the box to get the handles to resize the picture. I should say an insert picture window appears. I am not able to create a picture box at all. "Pinto" wrote: > Whenever I try to make a picture frame, I get an insert picture menu box > instead of the frame itself. Upon clicking cancel, the entire box, menu, is > deleted and I cannot get the box to get the handles to resize the picture. Pinto w...

How to get rid of 'excess' rows?
Hi all, I noticed one of my spreadsheets was a really big file (500K) for something that should have been very small. So I opened it and noticed that even though I only have data in the first 35 rows, the spreadsheet contains 9000+ rows. I imagine there is some formatting or something that is telling Excel to keep all the rows as part of my file, and I don't know how to get rid of the rows. I can't just copy and paste the data into a new spreadsheet because I have a lot of formatting in the rows/columns that I don't wish to have to recreate. Thanks! BTW: OS is Win98, Excel ve...

Compiling DLLs with name mangled names
I'm trying to write a wrapper to jvm.dll, but I can't keep the compiler from demangling the names of the exported functions. I have a jvm.def file with the name mangled names that I want: EXPORTS ??_7ASPSOldGenff@6B@=__E__0__ @1 ??_7ASPSYoungGen6B@=__E__1__ @2 .... And a jvm.cpp with function stubs with this signatures: extern "C" __declspec(naked) void __stdcall __E__0__() .... After compiling and linking the names of the exported functions are demangled. How can I compile the dll without demangling the names? My compiler and linker options: CL.EXE /O2 /GL /I ".&q...

Receiving email addressed to non-existent users in my domain
I'm using Exchange 2000 with GFI MailEssentials spam filter. I'm trying to figure out how email addressed to non-existent users in my domain wind up coming to me. Although I administer my Exchange installation I have not designated an administrator within Exchange Server. If I send an email from my personal Yahoo account to one of the accounts I've received email for it gets rejected as undeliverable by my Exchange server. However, when spammers sends to that address it gets through to me and I don't know how. GFI identifies it as spam and moves it to my spam folder but I recei...

name could not be matched
I have one client no matter what I do she cannot check her mail box. Here is the error message : The name could not be matched to a name in the address list. We are using Exchange 5.5 host on NT server 4.0 and outlook 2003. I reinstall outlook still the same problem. Any help will be greatly appreciated ...

Need to change user acct. from mail enabled to mailbox enabled
We currently have a consultant working for us whose AD user account is mail enabled. All email is forwarded to his personal email address. We now want him to have a mailbox on the Exchange server, but I don't know how to transition his account from mail enabled to mailbox enabled. I could remove the exchange attributes and start over, but I get a dire warning when I start to go down that road. I've tried adding a new smtp address for him and making it the primary, but that doesn't create a corresponding mailbox on the server. Any suggestions? Thanks in advance ~ Jim ...

email spoofed by local user (April Fools)
Recently (on April fools day) one of our local users spoofed an email to look like the CTO created it and sent it to the rest of the organization. Very funny (unless you are the Exchange administrator). We run Exchange 2003 and I need to fix this problem so it doesn't happen again. Right now if I telnet the mail server and issue the right commands (mail from:, rcpt to:, etc.) I can send an email with any non local address in the "mail from:" field to any user at my domain without authentication, which is how it must be since you can't expect users from other organizati...

Director doesn't want a user to receive/send email
I have a user is using the Outlook 2007 client, the director doesn't want this user to be able to send/receive email from inside and/or outside addresses she only wants this person to access calendars from w/in their department and schedule appointments. How can I disable this? I tried to delete the smtp address (won't allow it) and I tried to remove them from the address book (didn't seem to matter). To disable receiving from anyone: ADUC | recipient properties | Exchange General | Delivery Restrictions | Accept Messages -> select "Only From" | click "...

new mailbox enabled accounts don't get mailbox
When creating a new user w/a mailbox enabled account in AD the mailbox doesn't get created. The recipient policy e- mail addresses are not created in the users object properties. If I manually add the addresses I get the following error in the Exchange server application log. "Failed to read attribute msExchUserAccountControl from Active directory for o=domain/ou=first administrative group/cn=recipients/cn=username". The source is MSExchangeIS, catatory general, event ID 9562. When I check the more information link I get a little more info about file name mdbmsg.dll...

outlook keeps saying offline how to get over this problem?
I can not get Microsoft office outlook to open keeps saying that cannot open offline and that I can not get on line connection with it even though my internet was on line. I need this to sync my mobile urgently so anyone got any ideas????? PLEASE!! ...

Finding name of exception method
Hi Is it possible to collect name of method, line, file etc in which exception occurred? I have heard its possible using System.Diagnostics.StackTrace but not sure how. Many Thanks Regards On Mar 23, 11:46=A0am, "John" <i...@nospam.infovis.co.uk> wrote: > Hi > > Is it possible to collect name of method, line, file etc in which excepti= on > occurred? I have heard its possible using System.Diagnostics.StackTrace b= ut > not sure how. > > Many Thanks > > Regards Handle exception in a try-catch block and call stacktrace p...

User Guide
I have been trying to open the User guide for 2004 and it doesn't. So I follow the steps to preform to fix this and it still will not open. What am I doing wrong You can access the user's guide on the web here: http://www.microsoft.com/money/support/manual/ Tina wrote: > I have been trying to open the User guide for 2004 and it > doesn't. So I follow the steps to preform to fix this and > it still will not open. What am I doing wrong Are we talking on-line help? Try flushing your browser cache. "Tina" <anonymous@discussions.microsoft.com> wrote in ...

Japanese in file names
I have little or no problem using Japanese within a word or entourage document (apart from sometimes yampy character display within a word document that can be irritating), but none of the office apps can handle Japanese in the file names. Totally screws it up. Does anyone else suffer from the same problem, and if so can it be fixed, without buying a Japanese version of office. If I do get a Japanese version of office, is it possible to get the menus up in English? ...

Header/Footer File name extension
I've been using Excel for making quotes for my company. I put the file name as the quote number, and I used to have it show up without the file extension. Whenever a quote I did was printed on someone else's computer it would put the file extension on there. Now that I have a new computer and I'm back in Engineering, I don't do many quotes anymore. Yet lately I've done a couple and I have the file extension listed with the file name. How do I get rid of this? Any help would be appreciated. Thanks, Fred --- Message posted from http://www.ExcelForum.com/ Not sure w...

User account locked out
Bonjour! One of our user receive an error message "This User account has been lock out. Contact your Sys Admin." when trying to login into GP yesterday and she is still Locked out this morning. Joel :) Joe, Try the following 1. Go to Tools=>Utilities=>System=>User Activity and then Delete the User who is locked out. If this doesn't work out 2. Go to SQL, Run the script below in DYNAMICS Database DELETE FROM SY00800 WHERE USERID = 'XXX' ---Replace XXX with the User ID Thanks Janakiram M.P. MCP-GP "Joe" wrote: > Bonjour! One of our user re...