Link to home
Start Free TrialLog in
Avatar of nfernand
nfernand

asked on

Validating user agains NT server

Hi guys and girls.

I'm building a VB application that let some clients to access a database stored in a server (Win95). We do have a PDC (another NT server) that validate users on our network (Client for Microsoft Networks). I want to mimic Outlook ability (using VB) to know when a user is correctly validated on the network server. The database server won't be involved in the validation process (please) no advice on this way.

I want to do it this way to avoid users to manage another user id and password.

Note: Every one in here uses Microsoft Office2K, so I can reference Office objects and libraries if needed and possible.

Thanks...
Avatar of zafarbhat
zafarbhat

you can do it easily. their is one solution
first of all you have to implement domain networking in your environment. every user must log into the server for accessing his things else he is not allowed to do any thing. then you can retrieve user's information by using some windows api, like getusername and other related to support user access and access control.

Avatar of nfernand

ASKER

Thank you for your answer but...

1) Do not post an answer ever. This locks the question and no more people can see the question without paying. Do always post as comments. Comments can be accepted as regular answers and don't lock the question.

2) Domain networking is already implemented.

3) As I can remember, getusername tells me the name of the user using the pc, even if he isn't correctly loged. This is just a part of the solution: the user name. I need to validate him on the network.

4) What I think (I'm not sure) Outlook does is a kind of talking to the PDC or BDC (there are some BDCs too) to check if the PC and/or the user are correctly logged on the network. For example: if I log in a pc using my user name and try to access another pal's email box, outlook simply doesn't work and doesn't let me send or receive email using my pal's ID.

I know this is a hard one. I've posted this question using other words but never found an answer. If some one can help me I will (I promisse) upgrade the question up to 300 points or more.

Thanks again zafarbhat... a big hug.

-----------------------------

This is the same question: Can a MySql server validate users agains a PDC or BDC?
To be more specific I'm talking about a MySql database. (the MDB was a little mistake I want to leave).
You can try the following, which would require a user to put in their NT username and password, and this would verify that they are a correct pair. Is that what you want?

You can populate a logon screen with the current user's id using GetUserName - they only then require a password (their network password).

'=========================================
' Code to test NT username / password pair
' Paste into any form, etc and call
' CheckWindowsUser.
'=========================================

Option Explicit

Private Declare Function LogonUser Lib "Advapi32" Alias "LogonUserA" (ByVal _
    lpszUserName As String, ByVal lpszDomain As String, _
    ByVal lpszPassword As String, ByVal dwLogonType As Long, _
    ByVal dwLogonProvider As Long, phToken As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
    Long
Const LOGON32_PROVIDER_DEFAULT = 0&
Const LOGON32_LOGON_NETWORK = 3&

' Check whether a username/password pair is correct
'
' if DOMAIN is omitted, it uses the local account database
' and then asks trusted domains to search their account databases
' until it finds the account or the search is exhausted
' use DOMAIN="." to search only the local account database

Private Function CheckWindowsUser(ByVal UserName As String, _
    ByVal Password As String, Optional ByVal Domain As String) As Boolean

    Dim hToken As Long, ret As Long

    ' provide a default for the Domain name
    If Len(Domain) = 0 Then Domain = vbNullString
    ' check the username/password pair
    ' using LOGON32_LOGON_NETWORK delivers the best performance
    ret = LogonUser(UserName, Domain, Password, LOGON32_LOGON_NETWORK, _
        LOGON32_PROVIDER_DEFAULT, hToken)
   
    ' a non-zero value means success
    If ret Then
        CheckWindowsUser = True
        CloseHandle hToken
    End If

End Function
Hi and thank you.... can your code be used on a Win95 Client?
ASKER CERTIFIED SOLUTION
Avatar of matt_little_
matt_little_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Adminstrator are going to kill me but It will take some time for me to test this (I have an inminent trip to other city). I'll check it later but you have the points.

Thanks.
Thanks