Solved

Windows API, GetUserName is different with a Win2000 domain?

Posted on 2002-05-29
6
571 Views
Last Modified: 2013-12-03
Hi,

I have a piece of software that uses the GetUserName API function to get the user name of the logged in user and then does a case-sensitive match against a field in a database.  When our customer had their NT 4.0 domain this worked fine with both NT and 2000 clients.  The function returned the user name as stored in User Manager, rather than what they typed (as the NT login is NOT case-sensitive).

Since moving to a Windows 2000 domain, the GetUserName function appears to return exactly what they typed, rather than what is entered in User Manager, and the lookup against our database is now failing.

Is this by design, and is there a workaround for it (other than making my software force the name returned to upper or lower case!)

Thanks for any help you can offer,
Neil.
0
Comment
Question by:nplumridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 7041685
why are you doing a case-sesitive match on data that is case-in-sensitive. nt usernames are not case sensitive so why treat them as though they are.......
0
 

Author Comment

by:nplumridge
ID: 7041720
The name returned by GetUserName with an NT 4.0 doamin matched what was in User Manager, including the case.  With the Windows 2000 domain it just returns whatever you type on the login dialog, with whatever case you type it in.  I might just as well grab the USERNAME environment variable now.

I know I can just make the search case-insensitive, but I would like to know what has changed and why!
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 100 total points
ID: 7043828
It's impossible to say why this change was made. You have to bear in mind that Windows 2000 is not just a modification to NT 4--it's pretty much a ground-up rewrite (I've seen estimates that put the amount of rewritten and new code at over 80%), so it's entirely possible this works differently because it was written by a different programmer who decided to implement it in a different way.

In any case, I agree with makerp--even if the NT 4 GetUserName() returned a case-sensitive result, the actual check for a valid logon certainly doesn't take the case of the username into account, so there was never any point in doing a case-sensitive comparison in the first place.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question