locked
Check if NT Username exists (solved) RRS feed

  • Question

  • What I need is to verify that a username is a valid NT UserID for the current domain (or I can specify a domain if that makes it easier). I mean username only, I just want to know if the user exists on the domain, not authenticate them with credentials. The username I am trying to check is not necessarily the current windows user, but a login given to my application

    I am currently using the solution explained here (I actually changed "name" in that code to "sAMAccountName"), to get a list of all the usernames. The problem with this solution is it requires the user running my application to have administrator privileges.

    Does anyone have and solution to this that would not require administrator privileges?
    This does need to be in VB6.


    I am using Windows 7, but I want my solution to be compatible with XP, Vista and 7.

    I am trying to add a feature which allows the user to login to my application without a password IF they are a valid user in the application database AND a valid NT username on the domain. 

    Currently the only thing holding me back is the necessity of Admin privileges (no one wants to run a 3rd party app in admin mode). 

     

    Thanks for any help in advance!

    • Edited by WalterKovacs Thursday, September 2, 2010 8:42 PM
    Wednesday, September 1, 2010 8:47 PM

All replies

  • If anyone is curious I accomplished this with two WinAPI functions: 

    GetNetworkParams - To figure out the current domain. (http://vbnet.mvps.org/index.html?code/network/getdomainname.htm)

    NetUserGetInfo - If this returns a success code, then the user exists. (http://www.ex-designz.net/apidetail.asp?api_id=569)

    If you already have the domain, or want to use a specific domain instead of the current one, you can just use the second function. Googling either of those should bring up any needed info on them/how to use them in a different language.
    Thursday, September 2, 2010 8:42 PM