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
15 #include <afsconfig.h>
16 #include <afs/param.h>
22 #include "hourglass.h"
25 #include <afs/kautils.h>
26 #include "cm_config.h"
32 static char THIS_FILE[] = __FILE__;
36 CStringA CStringToCStringA(const CString& str)
41 #define PCCHAR(str) ((char *)(const char *)CStringToCStringA(str))
43 #define PCCHAR(str) ((char *)(const char *)str)
46 /////////////////////////////////////////////////////////////////////////////
49 int kl_Authenticate(const CString& strCellName, const CString& strName,
50 const CString& strPassword, char **reason)
54 return ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION,
62 CKlogDlg::CKlogDlg(CWnd* pParent /*=NULL*/)
65 InitModalIndirect (TaLocale_GetDialogResource (CKlogDlg::IDD), pParent);
67 //{{AFX_DATA_INIT(CKlogDlg)
69 m_strPassword = _T("");
70 m_strCellName = _T("");
72 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
75 void CKlogDlg::DoDataExchange(CDataExchange* pDX)
77 CDialog::DoDataExchange(pDX);
78 //{{AFX_DATA_MAP(CKlogDlg)
79 DDX_Control(pDX, IDOK, m_OK);
80 DDX_Text(pDX, IDC_NAME, m_strName);
81 DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
82 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
86 BEGIN_MESSAGE_MAP(CKlogDlg, CDialog)
87 //{{AFX_MSG_MAP(CKlogDlg)
88 ON_EN_CHANGE(IDC_NAME, OnChangeName)
89 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
90 ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
91 ON_BN_CLICKED(IDHELP, OnHelp)
95 /////////////////////////////////////////////////////////////////////////////
96 // CKlogDlg message handlers
98 BOOL CKlogDlg::OnInitDialog()
100 CDialog::OnInitDialog();
102 if (m_strCellName.IsEmpty()) {
103 char defaultCell[256];
104 long code = cm_GetRootCellName(defaultCell);
106 AfxMessageBox(_T("Error determining root cell name."));
108 m_strCellName = defaultCell;
113 return TRUE; // return TRUE unless you set the focus to a control
116 void CKlogDlg::OnOK()
124 if (kl_Authenticate(m_strCellName, m_strName, m_strPassword, &reason)) {
125 CString strReason(reason);
126 AfxMessageBox(strReason);
133 void CKlogDlg::OnChangeName()
138 void CKlogDlg::OnChangeCellName()
143 void CKlogDlg:: CheckEnableOk()
147 m_OK.EnableWindow(!m_strCellName.IsEmpty() && !m_strName.IsEmpty() && !m_strPassword.IsEmpty());
150 void CKlogDlg::OnChangePassword()
155 void CKlogDlg::OnHelp()
157 ShowHelp(m_hWnd, GET_TOKENS_HELP_ID);