Neither GetUserName not WNetGetUserName (which I assume is the particular WNetGet function argusy meant) will help you at all as, to all intents and purposes, they merely return the name of the currently logged in user.
What you probably need to look at is NetUserGetInfo API call at level 2 (i.e returning USER_INFO_2 structures), and then check the usri2_last_logon and usri2_last_logoff members of the structure. If the last_logon is later than the last_logoff then that particular user is logged in. One warning: each BDC in an NT4 domain retains it's own info for each user, so you'll actually need to check EVERY domain controller to get the most recent last_login and the most recent last_logoff values.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.