Solved

Windows API, GetUserName is different with a Win2000 domain?

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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