Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I validate an NT password?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00909838
Message ID:
00935091
Views:
31
David,

>>Long time, no talk to.
>
>I've been "quiet" for a couple of years. I've been lurking around the UT all the while, but back in full swing now. Good to see you still so active and valuable on this forum.

Your kind words are most appreciated.

>I'm coming over to SW Fox conference in Oct.

Drat! I won't be there.

>>
>>I just sent myself a message to bring the code from work home. I'll post it tomorrow.
>
>Appreciate that !

Try the following. If you have questions, just post back. This was written as a prototype for something I've done in C#. It's been heavily modified and, unfortunately, untested.
* Web Service: ValidateUser.prg
* Author: George Tasker
* Date: August 20, 2004
* Purpose: Validates that a user
* is registered in the domain

* Calling example:
* SET PROCEDURE TO ValidateUser
* oValid = CREATEOBJECT("ValidateUser")
* lvresult = oValid.ValidateUser('myname', 'mypassword', 'myforest')
* IF VARTYPE('lvresult') = L THEN 
*  * It's a bool
*   llresult = EVALUATE('lvresult')
* ELSE 
*  llresult = .F.
*  = MESSAGEBOX(lvresult, 0, "Validation Error")
* ENDIF 
* RETURN llresult

DEFINE CLASS ValidateUser AS Session OLEPUBLIC 

  FUNCTION ValidateUser(tcUser AS String, tcPassword AS String, tcForest AS String) OLEPUBLIC
    
    LOCAL lcresult AS String, loName AS NameTranslate,;
      lcAccount AS String, loLDAP AS LDAP, loLDAP2 AS LDAP,;
      oErr AS Exception, a_memberof, lcUser AS String, lcCRLF As String 
    lcresult = ""
    lcCRLF = CHR(13) + CHR(10)
    DIMENSION a_memberof[1]
    STORE NULL TO a_memberof
    lcUser = tcUser + '@' + tcForest
    loName = CREATEOBJECT('NameTranslate')
    loName.InitEx(3, "", lcUser, "", tcPassword)
    loName.Set(9, lcUser)
    lcAccount = loName.Get(1)
    IF NOT EMPTY(lcAccount) THEN 
      loLDAP = GETOBJECT("LDAP:")
      TRY 
        loLDAP2 = loLDAP.OpenDSObject("LDAP://" + lcAccount, lcAccount, tcPassword, 2)
      CATCH TO oErr
        lcresult = oErr.Message 
      FINALLY
        IF EMPTY(lcresult) THEN 
          a_memberof = loLDAP2.GetEx("MemberOF")
          lcresult = (ALEN(a_memberof, 1) > 0 AND NOT ISNULL(a_memberof[1]))
        ENDIF 
        STORE NULL TO loName, loLDAP, loLDAP2
      ENDTRY 
    ENDIF 
    RETURN lcresult
  ENDFUNC  
ENDDEFINE
You'll note that it's written for VFP 8.0 as a minimum.

Regards,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform