Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retrieve Password of logged in user!

Status
Not open for further replies.

AGP

Programmer
Sep 11, 2001
97
0
0
GB
Hi,
does anybody know of a method / api call which you can use to retrieve the Password of the currently logged in user. Many thanks.
 
I would have to ask why you want this type of info? If you are talking about the users password to log onto a PC, then I would suggest you are straying into the realms of hackerdom.
 
Hi,
the reason I want to be able to do this, is that I have created an application, which requires that I create a scheduled task. However, rather than presenting the user with the Scheduled Task dialog box, I wish to create the task without any user intervention and for this I need the username / password of the currently logged in user.
thanks.
 
Still no aparent need for the password. Username should (will?) suffice for the identity. The USER will know their password, and can / should supply it where necessary. Otherwise, you are just another hacker ... but that issue has already been raised.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Can't you run the task using a user-account setup specifically for the purpose of running scheduled tasks?
 
Hi,
first of all thankyou for all your replies to my question. In response to the last suggestion, I am not sure if I have explained what I am trying to do clearly enough. I am not trying to run a scheduled task, but instead create one the first time my program is started. To create the scheduled task I am using a third party component, which has the following properties;

dim obj as new component
obj.UserName = "me"
obj.Password = ?????
obj.CreateTask "mytask"

The third party component does allow me to display the Scheduled Task dialog box, but I would rather the task was created without any user intervention. Hope this helps and once again thankyou for all your help.
 
Won't that work the same way though?


dim obj as new component
obj.UserName = "ScheduledTaskUser"
obj.Password = "ScheduledTaskUserPassword"
obj.CreateTask "mytask"


It would mean having a password embedded in to your application, or else having the password in a file or the registry or something but I've seen that done before now.

As long as the ScheduledTaskUser account could create scheduled tasks that should be ok, unless your issue is that you need to know whos account the task is running under?

Daren
Must think of a witty signature
 
I agree with DarenNM, it would be better to use a generic Username/password, but if you want to know the user who is running the app use the api call(this works under NT4, not sure about other versions):

Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize as Long) _
As Long

lpBuffer is the user name.

This allows the use of specific username and generic pasword.
 
Why would your program (on startup) want to create a scheduled task a later time.

Sounds like the scheduled task is gonna create some mischief.

If this program only runs once and schedules the task, why not prompt the user for the password?

If this program is going to schedule tasks again and again, why not have a username/password as part of the options/preferences in your program. That would give the user control over who the tasks run as.

Otherwise it sounds really wishy washy to me.

The OS will never give up the password of the currently logged in user, so there is no use trying. The whole point is the logged in user should know his/her password. Therefore, that is who you should go to for the info.

-Bo -Adam T. Courtney
Stratagem, Inc.
 
I see your point, in that if the operating system were to give up the users password then this could lead to all kinds of security issues. However, I am sure I have seen a number of applications that create a scheduled task as part of their setup - often for the purposes of data maintenance!
I had a valid reason for creating a scheduled task in that my application needs to check and send any due messages held within my program on a daily basis. I thought that by creating the task behind the scenes would simplify the setup procedure. I think I will just have to prompt the user for their password!
thanks for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top