Main Page | Class List | File List | Class Members | File Members

ConfigPwd.cpp

Go to the documentation of this file.
00001 
00005 /*
00006 pGina ldapAuth code - based upon skeleton code for pGina plugin development
00007 Copyright (C) 2002 Micah Cooper
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 Email: coopermj@muohio.edu
00024 Snail Mail:
00025         Micah Cooper
00026         212A Kreger Hall
00027         Miami University
00028         Oxford OH  45056
00029 */
00030 // ConfigPwd.cpp : implementation file
00031 //
00032 
00033 #include "stdafx.h"
00034 #include "ldapauth_plus.h"
00035 #include "ConfigPwd.h"
00036 #include ".\configpwd.h"
00037 
00038 
00039 // CConfigPwd dialog
00040 
00041 IMPLEMENT_DYNAMIC(CConfigPwd, CDialog)
00042 CConfigPwd::CConfigPwd(CWnd* pParent /*=NULL*/)
00043         : CDialog(CConfigPwd::IDD, pParent)
00044         , m_requireLower(TRUE)
00045         , m_requireUpper(TRUE)
00046         , m_requireNumeric(TRUE)
00047         , m_requireSpecial(TRUE)
00048         , m_pwdMinLength(_T("8"))
00049         , m_disablePwd(FALSE)
00050         , m_restrictChars(_T(""))
00051 {
00052         CString temp;
00053 
00054         temp = regReadString(L"requireLower");
00055         if(temp.GetAt(0) == '1')
00056                 m_requireLower = true;
00057         else
00058                 m_requireLower = false;
00059 
00060         temp = regReadString(L"requireUpper");
00061         if(temp.GetAt(0) == '1')
00062                 m_requireUpper = true;
00063         else
00064                 m_requireUpper = false;
00065 
00066         temp = regReadString(L"requireNumeric");
00067         if(temp.GetAt(0) == '1')
00068                 m_requireNumeric = true;
00069         else
00070                 m_requireNumeric = false;
00071 
00072         temp = regReadString(L"requireSpecial");
00073         if(temp.GetAt(0) == '1')
00074                 m_requireSpecial = true;
00075         else
00076                 m_requireSpecial = false;
00077 
00078         m_pwdMinLength = regReadString(L"pwdMinLength");
00079         m_restrictChars = regReadString(L"restrictedChars");
00080 
00081         temp = regReadString(L"disablePwd");
00082         if(temp.GetAt(0) == '1') {
00083                 m_disablePwd = true;
00084         }
00085         else
00086                 m_disablePwd = false;
00087 }
00088 
00089 CConfigPwd::~CConfigPwd()
00090 {
00091 }
00092 
00093 void CConfigPwd::DoDataExchange(CDataExchange* pDX)
00094 {
00095         CDialog::DoDataExchange(pDX);
00096         DDX_Check(pDX, IDC_LOWERCASE, m_requireLower);
00097         DDX_Check(pDX, IDC_UPPERCASE, m_requireUpper);
00098         DDX_Check(pDX, IDC_NUMERIC, m_requireNumeric);
00099         DDX_Check(pDX, IDC_SPECIAL, m_requireSpecial);
00100         DDX_Text(pDX, IDC_PWD_LEN, m_pwdMinLength);
00101         DDX_Check(pDX, IDC_DISABLE_PWD, m_disablePwd);
00102         DDX_Text(pDX, IDC_RESTRICT_CHARS, m_restrictChars);
00103 
00104         DDX_Control(pDX, IDC_DISABLE_PWD, c_disablePwd);
00105         DDX_Control(pDX, IDC_MIN_STATIC, c_minLengthText);
00106         DDX_Control(pDX, IDC_PWD_LEN, c_pwdLenValue);
00107         DDX_Control(pDX, IDC_SPIN1, c_minSpin);
00108         DDX_Control(pDX, IDC_REST_STATIC, c_restrictText);
00109         DDX_Control(pDX, IDC_RESTRICT_CHARS, c_restrictChars);
00110         DDX_Control(pDX, IDC_REQ_STATIC, c_requiredText);
00111         DDX_Control(pDX, IDC_LOWERCASE, c_lowerCase);
00112         DDX_Control(pDX, IDC_UPPERCASE, c_upperCase);
00113         DDX_Control(pDX, IDC_NUMERIC, c_numeric);
00114         DDX_Control(pDX, IDC_SPECIAL, c_special);
00115 }
00116 
00117 
00118 BEGIN_MESSAGE_MAP(CConfigPwd, CDialog)
00119         ON_BN_CLICKED(IDC_DISABLE_PWD, OnDisableChangePwd)
00120 END_MESSAGE_MAP()
00121 
00122 
00123 // CConfigPwd message handlers
00124 void CConfigPwd::OnOK()
00125 {
00126         return;
00127 }
00128 
00129 BOOL CConfigPwd::OnInitDialog() 
00130 {
00131   CDialog::OnInitDialog();
00132   // Check if change password enabled
00133   OnDisableChangePwd();
00134 
00135   // Set buddy and range for spin button
00136   CSpinButtonCtrl* pSpinRange = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN1);
00137   pSpinRange->SetRange(0,15);
00138   pSpinRange->SetBuddy(GetDlgItem(IDC_PWD_LEN));
00139 
00140   return TRUE;  // Return TRUE unless you set the focus to a control.
00141                 // EXCEPTION: OCX Property Pages should return FALSE
00142 }
00143 
00144 void CConfigPwd::OnDisableChangePwd()
00145 {
00146         // TODO: Add your control notification handler code here
00147         // If checked, need to gray out other options
00148         if (c_disablePwd.GetCheck() == BST_CHECKED) {
00149                 c_minLengthText.EnableWindow(false);
00150                 c_pwdLenValue.EnableWindow(false);
00151                 c_minSpin.EnableWindow(false);
00152                 c_restrictChars.EnableWindow(false);
00153                 c_restrictText.EnableWindow(false);
00154                 c_requiredText.EnableWindow(false);
00155                 c_lowerCase.EnableWindow(false);
00156                 c_upperCase.EnableWindow(false);
00157                 c_numeric.EnableWindow(false);
00158                 c_special.EnableWindow(false);
00159         }
00160         else {
00161                 c_minLengthText.EnableWindow(true);
00162                 c_pwdLenValue.EnableWindow(true);
00163                 c_minSpin.EnableWindow(true);
00164                 c_restrictChars.EnableWindow(true);
00165                 c_restrictText.EnableWindow(true);
00166                 c_requiredText.EnableWindow(true);
00167                 c_lowerCase.EnableWindow(true);
00168                 c_upperCase.EnableWindow(true);
00169                 c_numeric.EnableWindow(true);
00170                 c_special.EnableWindow(true);
00171         }
00172 }
00173 
00174 void CConfigPwd::OnSave()
00175 {
00176         UpdateData(TRUE);
00177 
00178         if(m_requireLower)
00179                 regWriteString(TEXT("1"),L"requireLower");
00180         else
00181                 regWriteString(TEXT("0"),L"requireLower");
00182 
00183         if(m_requireUpper)
00184                 regWriteString(TEXT("1"),L"requireUpper");
00185         else
00186                 regWriteString(TEXT("0"),L"requireUpper");
00187 
00188         if(m_requireNumeric)
00189                 regWriteString(TEXT("1"),L"requireNumeric");
00190         else
00191                 regWriteString(TEXT("0"),L"requireNumeric");
00192 
00193         if(m_requireSpecial)
00194                 regWriteString(TEXT("1"),L"requireSpecial");
00195         else
00196                 regWriteString(TEXT("0"),L"requireSpecial");
00197 
00198         if(m_pwdMinLength.GetLength() > 0)
00199                 regWriteString(m_pwdMinLength.GetBuffer(m_pwdMinLength.GetLength()),L"pwdMinLength");
00200 
00201         if(m_restrictChars.GetLength() > 0)
00202                 regWriteString(m_restrictChars.GetBuffer(m_restrictChars.GetLength()),L"restrictedChars");
00203         else
00204                 regDelValue(L"restrictedChars");
00205 
00206         if(m_disablePwd)
00207                 regWriteString(TEXT("1"),L"disablePwd");
00208         else
00209                 regWriteString(TEXT("0"),L"disablePwd");
00210 }

Generated on Fri Feb 20 12:03:39 2004 for ldapauth plugin for pGina by doxygen 1.3.5