Solved

Windows API, GetUserName is different with a Win2000 domain?

Posted on 2002-05-29
6
568 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

827 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