* 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 ENDDEFINEYou'll note that it's written for VFP 8.0 as a minimum.