Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I validate an NT password?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00909838
Message ID:
00935447
Vues:
32
>David,
Hi George
It works fine if password if valid, but get an OLE error, "Access is denied" on this line
loName.InitEx(3, "", lcUser, "", tcPassword)
if either the password or user name (and possibly the domain/forest) is incorrect.

I've fixed a little bug in the calling example, see below.

So you're VERY close here.

Dave


>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
should be
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,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform