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__;
32 CStringA CStringToCStringA(const CString& str)
37 #define PCCHAR(str) ((char *)(const char *)CStringToCStringA(str))
39 #define PCCHAR(str) ((char *)(const char *)str)
42 /////////////////////////////////////////////////////////////////////////////
45 int kl_Authenticate(const CString& strCellName, const CString& strName,
46 const CString& strPassword, char **reason)
50 return ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION,
58 CKlogDlg::CKlogDlg(CWnd* pParent /*=NULL*/)
61 InitModalIndirect (TaLocale_GetDialogResource (CKlogDlg::IDD), pParent);
63 //{{AFX_DATA_INIT(CKlogDlg)
65 m_strPassword = _T("");
66 m_strCellName = _T("");
68 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
71 void CKlogDlg::DoDataExchange(CDataExchange* pDX)
73 CDialog::DoDataExchange(pDX);
74 //{{AFX_DATA_MAP(CKlogDlg)
75 DDX_Control(pDX, IDOK, m_OK);
76 DDX_Text(pDX, IDC_NAME, m_strName);
77 DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
78 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
82 BEGIN_MESSAGE_MAP(CKlogDlg, CDialog)
83 //{{AFX_MSG_MAP(CKlogDlg)
84 ON_EN_CHANGE(IDC_NAME, OnChangeName)
85 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
86 ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
87 ON_BN_CLICKED(IDHELP, OnHelp)
91 /////////////////////////////////////////////////////////////////////////////
92 // CKlogDlg message handlers
94 BOOL CKlogDlg::OnInitDialog()
96 CDialog::OnInitDialog();
98 if (m_strCellName.IsEmpty()) {
99 char defaultCell[256];
100 long code = cm_GetRootCellName(defaultCell);
102 AfxMessageBox(_T("Error determining root cell name."));
104 m_strCellName = defaultCell;
109 return TRUE; // return TRUE unless you set the focus to a control
112 void CKlogDlg::OnOK()
120 if (kl_Authenticate(m_strCellName, m_strName, m_strPassword, &reason)) {
121 CString strReason(reason);
122 AfxMessageBox(strReason);
129 void CKlogDlg::OnChangeName()
134 void CKlogDlg::OnChangeCellName()
139 void CKlogDlg:: CheckEnableOk()
143 m_OK.EnableWindow(!m_strCellName.IsEmpty() && !m_strName.IsEmpty() && !m_strPassword.IsEmpty());
146 void CKlogDlg::OnChangePassword()
151 void CKlogDlg::OnHelp()
153 ShowHelp(m_hWnd, GET_TOKENS_HELP_ID);