473,383 Members | 1,963 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,383 software developers and data experts.

get current user/domain

Hello,

does anyone know how to find out the logged in user with domain in vc++ ?

Thanks for help
Michael

Feb 10 '06 #1
4 2249
DPR
> does anyone know how to find out the logged in user with domain in vc++ ?

AppDomain::CurrentDomain->SetPrincipalPolicy(PrincipalPolicy::WindowsPrinci pal);
WindowsPrincipal^ user =
safe_cast<WindowsPrincipal^>(Thread::CurrentPrinci pal);

Console::WriteLine(user->Identity->Name);
Well, this will return the user information according to the security
context of the current thread ... i.e. you will get the user information
under which the current thread runs. Which is most likely what you wanna
have.

Won't work if you call this from a different security context, e.g.
inside a windows service application running under one of the system
accounts ...

--

DPR
Feb 10 '06 #2
> does anyone know how to find out the logged in user with domain in vc++ ?

the simplest method is probably to use
GetUserNameEx
it allows you to get different name formats that represent the current user.
the NT4 compatible format is of the form domain\user. you should be able to
parse this string without much problems to extract user name and domain.

another approach that uses the platform authentication functions can be
found in knowledgebase article Q111544:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/enu_kbwin32sdk/en-us/win32sdk/Q111544.htm

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 10 '06 #3
DPR
Sorry, that's of course the solution for VC++ using the managed extensions !

--

DPR
Feb 10 '06 #4
thank you both for help.
I'm working with the GetUserNameEx-function, it works great.

Best Regards
Michael
"Bruno van Dooren" wrote:
does anyone know how to find out the logged in user with domain in vc++ ?


the simplest method is probably to use
GetUserNameEx
it allows you to get different name formats that represent the current user.
the NT4 compatible format is of the form domain\user. you should be able to
parse this string without much problems to extract user name and domain.

another approach that uses the platform authentication functions can be
found in knowledgebase article Q111544:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/enu_kbwin32sdk/en-us/win32sdk/Q111544.htm

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"

Feb 11 '06 #5

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

Similar topics

1
by: hch_nguyen | last post by:
I am developing in the .NET Framework using vb.net running under Windows 2000 SP2. I have a snippet of code that runs to determine the name of the current windows user logged in. The code works...
0
by: Venkat | last post by:
Can any one tell me the way to check whether a given user name is a member of domain users or not. I do not know the domain name as well. I should retrieve from the logged in user, in which user...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
6
by: John Dalberg | last post by:
I want to automate the process of logging into an intranet. I want to pull out the username of the Windows user logged into the machine running the browser and use the username in my app. How can I...
5
by: Ron L | last post by:
I have an application I am developing which is using remoting to have a smart client connect to a remote database via IIS. There are certain functions that we only want the user to be able to...
4
by: Leszek | last post by:
Hello! I have my webpage (ASP) in domain (IIS 6.0). I need to make a popup with fullname of current user. How can I do this? Maybe someone have any examples? Thanks!
0
by: D-Someone | last post by:
We have an active directory user that just had her username renamed. When the user is running an application that calls our CurrentUser web service method (which returns the value of...
1
by: ranju | last post by:
I am trying to spawn a process (say an exe file) with different user crendentials than that of the current user. 1) Called LogonUserEx() to logon the user and recieve a handle to the token that...
3
by: Depechie | last post by:
Hey guys, small question. Can I find out if the current logged on use is a local user or a domain user ? And please don't use any solution that uses String parsing... What I need is to get...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.