Solved

validate active directory login information

Posted on 2004-08-22
5
224 Views
Last Modified: 2012-08-14
Hello,

I'm going to write an server application that shall check the login information (Windows 2000 domain) given by a client.
How can I realize that issue? Because I've some code that shall do that, but it throws an error. There is a limitation in Windows, so a user can only be logged on once. The outcome of these is, that the logged on user could be authorized but any other user/password combination not.

Here is the code:
Private Function IsAuthenticated(ByVal strUserName As String, ByVal strPassword As String) As Boolean
On Error Resume Next
    Dim strADsPath      As String
    Dim iFlags          As String
    Dim strADsNamespace As String
   
    Dim oADsObject      As Object
    Dim oADsNamespace   As Object
   
    strADsPath = "WinNT://" & m_strDomain
    iFlags = "0"
   
    ' bind to the ADSI object and authenticate Username and password
    Set oADsObject = GetObject(strADsPath)
    strADsNamespace = left(strADsPath, InStr(strADsPath, ":"))
    Set oADsNamespace = GetObject(strADsNamespace)
    Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, m_strDomain & "\" & strUserName, strPassword, 0)
   
    ' we're only bound if err.number = 0
    IsAuthenticated = (Err.Number = 0)
End Function


I read that it could be done with LDAP, but how to use it in VB6?
Or is there a way around the mentured login limitation?

best regards
Martin
0
Comment
Question by:mkrell
[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
  • 3
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 11866542
One way to do this is by changing the user's password.  To do that you have to supply the current password.  If the current password is wrong, then the change will fail and you'll know the current password si wrong.  This works okay, unless you have a policy in place that says a certain amount of time must pass after a password change before the user can change their password a second time.  Here's an example of this approach.  Look about half-way down in the code for a function called IsGoodPWD.

http://www.freevbcode.com/ShowCode.Asp?ID=4935

0
 
LVL 1

Author Comment

by:mkrell
ID: 11926554
Ok that may work...
But in my opinion it's a bit strange to change the passwords for validating them. Is there no other way?

I found some VB.NET Code using LDAP to solute that... But I couldn't translate it to VB 6
0
 
LVL 76

Expert Comment

by:David Lee
ID: 11926758
I seem to remember seeing one somewhere but I can't find it again.  I'll keep looking and if I find it I'll post it here.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 125 total points
ID: 12377069
I'd forgotten about this question.  I found the item I was thinking of.  It doesn't use LDAP though.  Here it is: http://vbnet.mvps.org/index.html?code/network/acceptsecuritycontext.htm 

If this isn't what you're looking for, then I recommend that the question be closed and a refund given.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
Adding to a VBA? 6 85
Modifying Conditional Format from VBA code 3 72
add criteria to query in VB, Access 2003 2 32
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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