Board index » Visual Studio » Function isPwdOk(strMail as String, strPwd as String) As Boolean
|
Maheshkumar
|
Function isPwdOk(strMail as String, strPwd as String) As Boolean
Visual Studio336
I'm trying to write a function used by an ASP 1.1 page that will verify if the user's password (entrered in a form) is the password found in the active directory. My philosophy is that a user should be able to read his own AD account. thus, in that sense, I created a call to the LDAP to retreive the user's account, and have him get his own cn. if he can get his cn, then it means the password was ok. if he gets butted out, it means that the password was wrong (on the asp form, I redirect the user to the login page). Problem is, the function seems to make IIS start looping until the page times out. my only worry is that maybe a user is not allowed to get his own cn using OpenDSObject. Can someone point me in the right direction? thanks. =3D=3D=3D=3D=3D=3D=3DFUNCTION BELOW=3D=3D=3D=3D=3D=3D=3D=3D=3D Public Function isPwdOk(strMailUser As String, strUserPwd As String) As Boolean On Error GoTo errIsPwdOk Dim strCnUser As String Dim adsLdap As IADsOpenDSObject Dim adsUser As IADsUser Dim adsPath As String Dim strErrMsg As String Dim strUserCnAD As String strCnUser =3D getUserCnFromMail(strMailUser) 'Bind sur l'annuaire LDAP avec le compte donn=E9 en entr=E9e Set adsLdap =3D GetObject("LDAP:") adsPath =3D "LDAP://" & strDomainServer & "/cn=3D" & strCnUser & ",cn=3DUsers," & strDomainLDAP Set adsUser =3D adsLdap.OpenDSObject(adsPath, strMailUser, strUserPwd, 0) strUserCnAD =3D adsUser.Get("cn") Set adsUser =3D Nothing Set adsLdap =3D Nothing If strCnUser =3D strUserCnAD Then isPwdOk =3D True Else isPwdOk =3D False End If Exit Function errIsPwdOk: Select Case Err.Number Case ERROR_DS_SERVER_DOWN: 'Annuaire LDAP non disponible strErrMsg =3D "Annuaire LDAP non disponible (" & adsPath & ")" Case Else strErrMsg =3D Err.Description End Select MsgBox strErrMsg, vbCritical, "BpAdminAD.isPwdOk" Err.Raise Err.Number, "BpAdminAD.isPwdOk", strErrMsg End Function =3D=3D=3D=3D=3D=3D=3DFUNCTION ABOVE=3D=3D=3D=3D=3D=3D=3D=3D=3D - |
