2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
17 #include "hourglass.h"
20 #include <afs/param.h>
21 #include <afs/kautils.h>
22 #include "cm_config.h"
28 static char THIS_FILE[] = __FILE__;
31 #define PCCHAR(str) ((char *)(const char *)str)
34 /////////////////////////////////////////////////////////////////////////////
37 int kl_Authenticate(const CString& strCellName, const CString& strName, const CString& strPassword, char **reason)
41 return ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, PCCHAR(strName), "", PCCHAR(strCellName), PCCHAR(strPassword), 0, &pw_exp, 0, reason);
44 CKlogDlg::CKlogDlg(CWnd* pParent /*=NULL*/)
47 InitModalIndirect (TaLocale_GetDialogResource (CKlogDlg::IDD), pParent);
49 //{{AFX_DATA_INIT(CKlogDlg)
51 m_strPassword = _T("");
52 m_strCellName = _T("");
54 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
57 void CKlogDlg::DoDataExchange(CDataExchange* pDX)
59 CDialog::DoDataExchange(pDX);
60 //{{AFX_DATA_MAP(CKlogDlg)
61 DDX_Control(pDX, IDOK, m_OK);
62 DDX_Text(pDX, IDC_NAME, m_strName);
63 DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
64 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
68 BEGIN_MESSAGE_MAP(CKlogDlg, CDialog)
69 //{{AFX_MSG_MAP(CKlogDlg)
70 ON_EN_CHANGE(IDC_NAME, OnChangeName)
71 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
72 ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
73 ON_BN_CLICKED(IDHELP, OnHelp)
77 /////////////////////////////////////////////////////////////////////////////
78 // CKlogDlg message handlers
80 BOOL CKlogDlg::OnInitDialog()
82 CDialog::OnInitDialog();
84 if (m_strCellName.IsEmpty()) {
85 char defaultCell[256];
86 long code = cm_GetRootCellName(defaultCell);
88 AfxMessageBox("Error determining root cell name.");
90 m_strCellName = defaultCell;
95 return TRUE; // return TRUE unless you set the focus to a control
106 if (kl_Authenticate(m_strCellName, m_strName, m_strPassword, &reason)) {
107 AfxMessageBox(reason);
114 void CKlogDlg::OnChangeName()
119 void CKlogDlg::OnChangeCellName()
124 void CKlogDlg:: CheckEnableOk()
128 m_OK.EnableWindow(!m_strCellName.IsEmpty() && !m_strName.IsEmpty() && !m_strPassword.IsEmpty());
131 void CKlogDlg::OnChangePassword()
136 void CKlogDlg::OnHelp()
138 ShowHelp(m_hWnd, GET_TOKENS_HELP_ID);