Solved

Windows API, GetUserName is different with a Win2000 domain?

Posted on 2002-05-29
6
562 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
6 Comments
 
LVL 10

Expert Comment

by:makerp
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now