Initial import of KFW 3.2.2 Leash32 code
authorSam Hartman <hartmans@mit.edu>
Wed, 28 Sep 2011 21:02:14 +0000 (21:02 +0000)
committerSam Hartman <hartmans@mit.edu>
Wed, 28 Sep 2011 21:02:14 +0000 (21:02 +0000)
Signed-off-by: Alexey Melnikov <aamelnikov@gmail.com>
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25278 dc483132-0cff-0310-8789-dd5450dbe970

106 files changed:
src/windows/leash/AfsProperties.cpp [new file with mode: 0644]
src/windows/leash/AfsProperties.h [new file with mode: 0644]
src/windows/leash/CLeashDragListBox.cpp [new file with mode: 0644]
src/windows/leash/CLeashDragListBox.h [new file with mode: 0644]
src/windows/leash/Krb4AddToDomainRealmList.cpp [new file with mode: 0644]
src/windows/leash/Krb4AddToDomainRealmList.h [new file with mode: 0644]
src/windows/leash/Krb4AddToRealmHostList.cpp [new file with mode: 0644]
src/windows/leash/Krb4AddToRealmHostList.h [new file with mode: 0644]
src/windows/leash/Krb4DomainRealmMaintenance.cpp [new file with mode: 0644]
src/windows/leash/Krb4DomainRealmMaintenance.h [new file with mode: 0644]
src/windows/leash/Krb4EditDomainRealmList.cpp [new file with mode: 0644]
src/windows/leash/Krb4EditDomainRealmList.h [new file with mode: 0644]
src/windows/leash/Krb4EditRealmHostList.cpp [new file with mode: 0644]
src/windows/leash/Krb4EditRealmHostList.h [new file with mode: 0644]
src/windows/leash/Krb4Properties.cpp [new file with mode: 0644]
src/windows/leash/Krb4Properties.h [new file with mode: 0644]
src/windows/leash/Krb4RealmHostMaintenance.cpp [new file with mode: 0644]
src/windows/leash/Krb4RealmHostMaintenance.h [new file with mode: 0644]
src/windows/leash/Krb5Properties.cpp [new file with mode: 0644]
src/windows/leash/Krb5Properties.h [new file with mode: 0644]
src/windows/leash/KrbAddHostServer.cpp [new file with mode: 0644]
src/windows/leash/KrbAddHostServer.h [new file with mode: 0644]
src/windows/leash/KrbAddRealm.cpp [new file with mode: 0644]
src/windows/leash/KrbAddRealm.h [new file with mode: 0644]
src/windows/leash/KrbConfigOptions.cpp [new file with mode: 0644]
src/windows/leash/KrbConfigOptions.h [new file with mode: 0644]
src/windows/leash/KrbDomainRealmMaintenance.cpp [new file with mode: 0644]
src/windows/leash/KrbDomainRealmMaintenance.h [new file with mode: 0644]
src/windows/leash/KrbEditHostServer.cpp [new file with mode: 0644]
src/windows/leash/KrbEditHostServer.h [new file with mode: 0644]
src/windows/leash/KrbEditRealm.cpp [new file with mode: 0644]
src/windows/leash/KrbEditRealm.h [new file with mode: 0644]
src/windows/leash/KrbMiscConfigOpt.cpp [new file with mode: 0644]
src/windows/leash/KrbMiscConfigOpt.h [new file with mode: 0644]
src/windows/leash/KrbProperties.cpp [new file with mode: 0644]
src/windows/leash/KrbProperties.h [new file with mode: 0644]
src/windows/leash/KrbRealmHostMaintenance.cpp [new file with mode: 0644]
src/windows/leash/KrbRealmHostMaintenance.h [new file with mode: 0644]
src/windows/leash/Leash.cpp [new file with mode: 0644]
src/windows/leash/Leash.h [new file with mode: 0644]
src/windows/leash/Leash.rc [new file with mode: 0644]
src/windows/leash/LeashAboutBox.cpp [new file with mode: 0644]
src/windows/leash/LeashAboutBox.h [new file with mode: 0644]
src/windows/leash/LeashControlPanel.cpp [new file with mode: 0644]
src/windows/leash/LeashControlPanel.h [new file with mode: 0644]
src/windows/leash/LeashDebugWindow.cpp [new file with mode: 0644]
src/windows/leash/LeashDebugWindow.h [new file with mode: 0644]
src/windows/leash/LeashDoc.cpp [new file with mode: 0644]
src/windows/leash/LeashDoc.h [new file with mode: 0644]
src/windows/leash/LeashFileDialog.cpp [new file with mode: 0644]
src/windows/leash/LeashFileDialog.h [new file with mode: 0644]
src/windows/leash/LeashFrame.cpp [new file with mode: 0644]
src/windows/leash/LeashFrame.h [new file with mode: 0644]
src/windows/leash/LeashMessageBox.cpp [new file with mode: 0644]
src/windows/leash/LeashMessageBox.h [new file with mode: 0644]
src/windows/leash/LeashProperties.cpp [new file with mode: 0644]
src/windows/leash/LeashProperties.h [new file with mode: 0644]
src/windows/leash/LeashView.cpp [new file with mode: 0644]
src/windows/leash/LeashView.h [new file with mode: 0644]
src/windows/leash/Lglobals.cpp [new file with mode: 0644]
src/windows/leash/Lglobals.h [new file with mode: 0644]
src/windows/leash/MainFrm.cpp [new file with mode: 0644]
src/windows/leash/MainFrm.h [new file with mode: 0644]
src/windows/leash/StdAfx.cpp [new file with mode: 0644]
src/windows/leash/StdAfx.h [new file with mode: 0644]
src/windows/leash/VSroutines.c [new file with mode: 0644]
src/windows/leash/reminder.h [new file with mode: 0644]
src/windows/leash/res/Leash.ico [new file with mode: 0644]
src/windows/leash/res/Leash.rc2 [new file with mode: 0644]
src/windows/leash/res/Leash2.ico [new file with mode: 0644]
src/windows/leash/res/Leash_Doc.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tickets_green.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tickets_orange.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tickets_out.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tickets_red.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tkt_green.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tkt_orange.ico [new file with mode: 0644]
src/windows/leash/res/Leash_tkt_red.ico [new file with mode: 0644]
src/windows/leash/res/Leash_toolbar.bmp [new file with mode: 0644]
src/windows/leash/res/Leash_user_green.ico [new file with mode: 0644]
src/windows/leash/res/Leash_user_orange.ico [new file with mode: 0644]
src/windows/leash/res/Leash_user_out.ico [new file with mode: 0644]
src/windows/leash/res/Leash_user_red.ico [new file with mode: 0644]
src/windows/leash/res/address.ico [new file with mode: 0644]
src/windows/leash/res/cursor1.cur [new file with mode: 0644]
src/windows/leash/res/destroy.ico [new file with mode: 0644]
src/windows/leash/res/destroy_disabled.ico [new file with mode: 0644]
src/windows/leash/res/doghead_green.ico [new file with mode: 0644]
src/windows/leash/res/doghead_grey.ico [new file with mode: 0644]
src/windows/leash/res/doghead_orange.ico [new file with mode: 0644]
src/windows/leash/res/doghead_red.ico [new file with mode: 0644]
src/windows/leash/res/encryption.ico [new file with mode: 0644]
src/windows/leash/res/import.ico [new file with mode: 0644]
src/windows/leash/res/import_disabled.ico [new file with mode: 0644]
src/windows/leash/res/key.ico [new file with mode: 0644]
src/windows/leash/res/new.ico [new file with mode: 0644]
src/windows/leash/res/new_disabled.ico [new file with mode: 0644]
src/windows/leash/res/password.ico [new file with mode: 0644]
src/windows/leash/res/password_disabled.ico [new file with mode: 0644]
src/windows/leash/res/refresh.ico [new file with mode: 0644]
src/windows/leash/res/refresh_disabled.ico [new file with mode: 0644]
src/windows/leash/res/renew.ico [new file with mode: 0644]
src/windows/leash/res/renew_disabled.ico [new file with mode: 0644]
src/windows/leash/res/sync.ico [new file with mode: 0644]
src/windows/leash/res/sync_disabled.ico [new file with mode: 0644]
src/windows/leash/resource.h [new file with mode: 0644]

diff --git a/src/windows/leash/AfsProperties.cpp b/src/windows/leash/AfsProperties.cpp
new file mode 100644 (file)
index 0000000..dabcdfd
--- /dev/null
@@ -0,0 +1,123 @@
+// AfsProperties.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leash.h"
+#include "AfsProperties.h"
+
+/* This should be set to something other than 0 or 1 (the valid values) */
+#define INVALID_AFS_STATUS_VALUE 2
+#define IS_INVALID_AFS_STATUS_VALUE(x) ((x != 0) && (x != 1))
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CAfsProperties dialog
+
+
+CAfsProperties::CAfsProperties(CWnd* pParent /*=NULL*/)
+       : CDialog(CAfsProperties::IDD, pParent)
+{
+    m_newAfsStatus = 0;
+    m_oldAfsStatus = 0;
+
+    //{{AFX_DATA_INIT(CAfsProperties)
+    // NOTE: the ClassWizard will add member initialization here
+    //}}AFX_DATA_INIT
+}
+
+
+void CAfsProperties::DoDataExchange(CDataExchange* pDX)
+{
+    CDialog::DoDataExchange(pDX);
+    //{{AFX_DATA_MAP(CAfsProperties)
+    // NOTE: the ClassWizard will add DDX an3d DDV calls here
+    //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CAfsProperties, CDialog)
+    //{{AFX_MSG_MAP(CAfsProperties)
+    ON_BN_CLICKED(IDC_BUTTON_AFS_PROPERTIES, OnButtonAfsProperties)
+    ON_BN_CLICKED(IDC_RADIO_AFS_ENABLED, OnRadioAfsEnabled)
+    ON_BN_CLICKED(IDC_RADIO_AFS_DISABLED, OnRadioAfsDisabled)
+    ON_COMMAND(ID_HELP, OnHelp)
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CAfsProperties message handlers
+
+BOOL
+CAfsProperties::OnInitDialog()
+{
+    CDialog::OnInitDialog();
+
+    // Get State* of Destroy Tickets On Exit
+    m_pApp = AfxGetApp();
+
+    m_oldAfsStatus = m_pApp->GetProfileInt("Settings", "AfsStatus",
+                                           INVALID_AFS_STATUS_VALUE);
+    if (IS_INVALID_AFS_STATUS_VALUE(m_oldAfsStatus))
+    {
+        // set the default
+        m_pApp->WriteProfileInt("Settings", "AfsStatus", 1);
+        m_oldAfsStatus = 1;
+    }
+
+    m_newAfsStatus = m_oldAfsStatus;
+
+    int enabled = (m_oldAfsStatus != 0);
+    if (enabled)
+        CheckDlgButton(IDC_RADIO_AFS_ENABLED, TRUE);
+    else
+        CheckDlgButton(IDC_RADIO_AFS_DISABLED, TRUE);
+
+    return TRUE;
+}
+
+void CAfsProperties::OnButtonAfsProperties()
+{
+    if (32 >= (LRESULT) ShellExecute (NULL, NULL, "AFS_CONFIG.EXE", NULL,
+                                      NULL, SW_SHOW))
+    {
+        MessageBox("Can't find file AFS_CONFIG.EXE", "Error", MB_OK);
+    }
+}
+
+void CAfsProperties::OnOK()
+{
+    if (m_oldAfsStatus != m_newAfsStatus)
+    {
+        if (!m_pApp->WriteProfileInt("Settings", "AfsStatus", m_newAfsStatus))
+        {
+            MessageBox("There was an error putting your entry into the "
+                       "Registry!", "Error", MB_OK);
+        }
+    }
+
+    CDialog::OnOK();
+}
+
+void CAfsProperties::OnRadioAfsEnabled()
+{
+       m_newAfsStatus = 1;
+}
+
+void CAfsProperties::OnRadioAfsDisabled()
+{
+       m_newAfsStatus = 0;
+}
+
+void CAfsProperties::OnHelp()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_AFS_PROPERTIES_COMMAND);
+#else
+    AfxGetApp()->WinHelp(HID_AFS_PROPERTIES_COMMAND);
+#endif
+}
diff --git a/src/windows/leash/AfsProperties.h b/src/windows/leash/AfsProperties.h
new file mode 100644 (file)
index 0000000..2c6e1ed
--- /dev/null
@@ -0,0 +1,56 @@
+#if !defined(AFX_AFSPROPERTIES_H__FD135601_2FCB_11D3_96A2_0000861B8A3C__INCLUDED_)
+#define AFX_AFSPROPERTIES_H__FD135601_2FCB_11D3_96A2_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AfsProperties.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CAfsProperties dialog
+
+class CAfsProperties : public CDialog
+{
+// Construction
+private:
+    UINT m_newAfsStatus;
+    UINT m_oldAfsStatus;
+    CWinApp *m_pApp;
+
+public:
+       CAfsProperties(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CAfsProperties)
+       enum { IDD = IDD_AFS_PROPERTIES };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CAfsProperties)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CAfsProperties)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnButtonAfsProperties();
+       virtual void OnOK();
+       afx_msg void OnRadioAfsEnabled();
+       afx_msg void OnRadioAfsDisabled();
+    afx_msg void OnHelp();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_AFSPROPERTIES_H__FD135601_2FCB_11D3_96A2_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/CLeashDragListBox.cpp b/src/windows/leash/CLeashDragListBox.cpp
new file mode 100644 (file)
index 0000000..205889b
--- /dev/null
@@ -0,0 +1,215 @@
+#include "stdafx.h"
+#include "CLeashDragListBox.h"
+#include "leash.h"
+#include "lglobals.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashDragListBox
+
+//IMPLEMENT_DYNAMIC(CLeashDragListBox, CDragListBox)
+
+CLeashDragListBox::CLeashDragListBox()
+ :CDragListBox()
+{
+
+}
+
+CLeashDragListBox::~CLeashDragListBox()
+{
+       DestroyWindow();
+}
+
+void CLeashDragListBox::initOtherListbox(CPropertyPage* pPage, CListBox* pOtherListBox)
+{
+       m_pPage = pPage;
+       m_pOtherListBox = pOtherListBox;
+}
+
+
+void CLeashDragListBox::PreSubclassWindow()
+{
+       ASSERT(::IsWindow(m_hWnd));
+       ASSERT((GetStyle() & (LBS_MULTIPLESEL|LBS_SORT)) == 0);
+       MakeDragList(m_hWnd);
+}
+
+BOOL CLeashDragListBox::BeginDrag(CPoint pt)
+{
+       m_nLast = -1;
+       DrawInsert(ItemFromPt(pt));
+       return TRUE;
+}
+
+void CLeashDragListBox::CancelDrag(CPoint)
+{
+       DrawInsert(-1);
+}
+
+UINT CLeashDragListBox::Dragging(CPoint pt)
+{
+       int nIndex = ItemFromPt(pt, FALSE); // don't allow scrolling just yet
+       DrawInsert(nIndex);
+       ItemFromPt(pt);
+       return (nIndex == LB_ERR) ? DL_STOPCURSOR : DL_MOVECURSOR;
+}
+
+void CLeashDragListBox::Dropped(int nSrcIndex, CPoint pt)
+{
+       ASSERT(!(GetStyle() & (LBS_OWNERDRAWFIXED|LBS_OWNERDRAWVARIABLE)) ||
+               (GetStyle() & LBS_HASSTRINGS));
+
+       DrawInsert(-1);
+       int nDestIndex = ItemFromPt(pt);
+
+       if (nSrcIndex == -1 || nDestIndex == -1)
+               return;
+       if (nDestIndex == nSrcIndex || nDestIndex == nSrcIndex+1)
+               return; //didn't move
+       CString str1, str2;
+       DWORD dwData;
+       GetText(nSrcIndex, str1);
+       GetText(nDestIndex, str2);
+       dwData = GetItemData(nSrcIndex);
+       DeleteString(nSrcIndex);
+       if (nSrcIndex < nDestIndex)
+               nDestIndex--;
+       nDestIndex = InsertString(nDestIndex, str1);
+       SetItemData(nDestIndex, dwData);
+       SetCurSel(nDestIndex);
+
+       // Save new order of items to profile linklist
+       char theSection[REALM_SZ + 1];
+       const char*  adminServer[] = {"realms", theSection, ADMIN_SERVER, NULL};
+       const char* Section[] = {"realms", theSection, NULL};
+       const char** adminServ = adminServer;
+       const char** section = Section;
+       const char* valueSection[] = {"realms", theSection, "kdc", NULL};
+       const char** valueSec = valueSection;
+       CString theValue;
+       CHAR hostServer[MAX_HSTNM];
+
+       if (LB_ERR == m_pOtherListBox->GetText(m_pOtherListBox->GetCurSel(), theSection))
+      ASSERT(0);
+
+       long retval = pprofile_rename_section(CLeashApp::m_krbv5_profile,
+                                                                                  section, NULL);
+       if (retval)
+       {
+               MessageBox("Dropped::There is on error, profile will not be saved!!!\
+                   \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+       retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                   section, NULL);
+       if (retval)
+       {
+               MessageBox("Dropped::There is on error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+       for (INT maxItems = GetCount(), item = 0; item < maxItems; item++)
+       {
+               GetText(item, hostServer);
+               //strcpy(hostServer, theValue);
+
+               if (strstr(hostServer, ADMIN_SERVER))
+               {
+                       char* pAdmin = strchr(hostServer, ' ');
+                       if (pAdmin)
+                         *pAdmin = 0;
+                       else
+                         ASSERT(0);
+
+                       retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                                       adminServ, hostServer);
+                       if (retval)
+                       {
+                               MessageBox("Dropped::There is on error, profile will not be saved!!!\
+                           \nIf this error persist, contact your administrator.",
+                                                  "Leash", MB_OK);
+                               return;
+                       }
+               }
+
+               retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                               valueSec, hostServer);
+               if (retval)
+               {
+                       MessageBox("Dropped::There is on error, profile will not be saved!!!\
+                       \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return;
+               }
+       }
+
+       m_pPage->SetModified(TRUE);
+}
+
+void CLeashDragListBox::DrawInsert(int nIndex)
+{
+       if (m_nLast != nIndex)
+       {
+               DrawSingle(m_nLast);
+               DrawSingle(nIndex);
+               m_nLast = nIndex;
+       }
+}
+
+void CLeashDragListBox::DrawSingle(int nIndex)
+{
+       if (nIndex == -1)
+               return;
+       CBrush* pBrush = CDC::GetHalftoneBrush();
+       CRect rect;
+       GetClientRect(&rect);
+       CRgn rgn;
+       rgn.CreateRectRgnIndirect(&rect);
+
+       CDC* pDC = GetDC();
+       // prevent drawing outside of listbox
+       // this can happen at the top of the listbox since the listbox's DC is the
+       // parent's DC
+       pDC->SelectClipRgn(&rgn);
+
+       GetItemRect(nIndex, &rect);
+       rect.bottom = rect.top+2;
+       rect.top -= 2;
+       CBrush* pBrushOld = pDC->SelectObject(pBrush);
+       //draw main line
+       pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATINVERT);
+
+       pDC->SelectObject(pBrushOld);
+       ReleaseDC(pDC);
+}
+
+/*
+BOOL CLeashDragListBox::OnChildNotify(UINT nMessage, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
+{
+       if (nMessage != m_nMsgDragList)
+               return CListBox::OnChildNotify(nMessage, wParam, lParam, pResult);
+
+       ASSERT(pResult != NULL);
+       LPDRAGLISTINFO pInfo = (LPDRAGLISTINFO)lParam;
+       ASSERT(pInfo != NULL);
+       switch (pInfo->uNotification)
+       {
+       case DL_BEGINDRAG:
+               *pResult = BeginDrag(pInfo->ptCursor);
+               break;
+       case DL_CANCELDRAG:
+               CancelDrag(pInfo->ptCursor);
+               break;
+       case DL_DRAGGING:
+               *pResult = Dragging(pInfo->ptCursor);
+               break;
+       case DL_DROPPED:
+               Dropped(GetCurSel(), pInfo->ptCursor);
+               break;
+       }
+       return TRUE;
+}
+*/
diff --git a/src/windows/leash/CLeashDragListBox.h b/src/windows/leash/CLeashDragListBox.h
new file mode 100644 (file)
index 0000000..02179b2
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _LEASH_DRAGLISTBOX
+#define _LEASH_DRAGLISTBOX
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashDragListBox
+
+//#include "AFXCMN.h"
+
+class CLeashDragListBox : public CDragListBox
+{
+       //DECLARE_DYNAMIC(CDragListBoxCLeashDragListBox)
+
+       CListBox* m_pOtherListBox;
+       CPropertyPage* m_pPage;
+
+// Constructors
+public:
+       CLeashDragListBox();
+       void initOtherListbox(CPropertyPage* pPage, CListBox* pOtherListBox);
+
+// Attributes
+       //int ItemFromPt(CPoint pt, BOOL bAutoScroll = TRUE) const;
+
+// Operations
+       virtual void DrawInsert(int nItem);
+
+// Overridables
+       virtual BOOL BeginDrag(CPoint pt);
+       virtual void CancelDrag(CPoint pt);
+       virtual UINT Dragging(CPoint pt);
+       virtual void Dropped(int nSrcIndex, CPoint pt);
+
+// Implementation
+public:
+       int m_nLast;
+       void DrawSingle(int nIndex);
+       virtual void PreSubclassWindow();
+       virtual ~CLeashDragListBox();
+protected:
+       //virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
+};
+
+//class CLeashDragListBox;
+
+#endif // _LEASH_DRAGLISTBOX
diff --git a/src/windows/leash/Krb4AddToDomainRealmList.cpp b/src/windows/leash/Krb4AddToDomainRealmList.cpp
new file mode 100644 (file)
index 0000000..9f119bd
--- /dev/null
@@ -0,0 +1,107 @@
+//     File:                   Krb4AddToDomainRealmList.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4AddToDomainRealmList.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4AddToDomainRealmList.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToDomainRealmList dialog
+
+
+CKrb4AddToDomainRealmList::CKrb4AddToDomainRealmList(CWnd* pParent /*=NULL*/)
+       : CDialog(CKrb4AddToDomainRealmList::IDD, pParent)
+{
+       m_newRealm = _T("");
+       m_newDomainHost = _T("");
+       m_startup = TRUE;
+
+
+       //{{AFX_DATA_INIT(CKrb4AddToDomainRealmList)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CKrb4AddToDomainRealmList::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4AddToDomainRealmList)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4AddToDomainRealmList, CDialog)
+       //{{AFX_MSG_MAP(CKrb4AddToDomainRealmList)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_DOMAINHOSTNAME, OnChangeEditDomainhostname)
+       ON_EN_CHANGE(IDC_EDIT_DOMAINREALMNAME, OnChangeEditDomainrealmname)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToDomainRealmList message handlers
+
+void CKrb4AddToDomainRealmList::OnChangeEditDomainhostname()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_DOMAINHOSTNAME, m_newDomainHost);
+}
+
+void CKrb4AddToDomainRealmList::OnChangeEditDomainrealmname()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_DOMAINREALMNAME, m_newRealm);
+}
+
+void CKrb4AddToDomainRealmList::OnOK()
+{
+       //if (m_newRealm.IsEmpty)
+
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+       m_newDomainHost.TrimLeft();
+       m_newDomainHost.TrimRight();
+
+       if (m_newRealm.IsEmpty() || m_newDomainHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK::Both Realm and Domain-Host fields must be filled in!",
+                    "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' ') || -1 != m_newDomainHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+       else
+         CDialog::OnOK(); // exit
+}
+
+void CKrb4AddToDomainRealmList::OnCancel()
+{
+
+       CDialog::OnCancel();
+}
+
+void CKrb4AddToDomainRealmList::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
diff --git a/src/windows/leash/Krb4AddToDomainRealmList.h b/src/windows/leash/Krb4AddToDomainRealmList.h
new file mode 100644 (file)
index 0000000..8148c0d
--- /dev/null
@@ -0,0 +1,73 @@
+//     File:                   Krb4AddToDomainRealmList.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4AddToDomainRealmList.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_KRB4ADDTODOMAINREALMLIST_H__F4D41683_96A4_11D2_94E2_0000861B8A3C__INCLUDED_)
+#define AFX_KRB4ADDTODOMAINREALMLIST_H__F4D41683_96A4_11D2_94E2_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// Krb4AddToDomainRealmList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToDomainRealmList dialog
+
+class CKrb4AddToDomainRealmList : public CDialog
+{
+// Construction
+private:
+       CString m_newRealm;
+       CString m_newDomainHost;
+       BOOL m_newAdmin;
+       BOOL m_startup;
+
+public:
+       CKrb4AddToDomainRealmList(CWnd* pParent = NULL);   // standard constructor
+
+       CString GetNewRealm() {return m_newRealm;}
+       CString GetNewDomainHost() {return m_newDomainHost;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4AddToDomainRealmList)
+       enum { IDD = IDD_KRB4_ADD_DOMAINREALMNAME };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4AddToDomainRealmList)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4AddToDomainRealmList)
+       virtual void OnOK();
+       virtual void OnCancel();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnChangeEditDomainhostname();
+       afx_msg void OnChangeEditDomainrealmname();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRB4ADDTODOMAINREALMLIST_H__F4D41683_96A4_11D2_94E2_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb4AddToRealmHostList.cpp b/src/windows/leash/Krb4AddToRealmHostList.cpp
new file mode 100644 (file)
index 0000000..e012aea
--- /dev/null
@@ -0,0 +1,121 @@
+//     File:                   Krb4AddToRealmHostList.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4AddToRealmHostList.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4AddToRealmHostList.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToRealmHostList dialog
+
+
+CKrb4AddToRealmHostList::CKrb4AddToRealmHostList(CWnd* pParent /*=NULL*/)
+: CDialog(CKrb4AddToRealmHostList::IDD, pParent)
+{
+       m_newRealm = _T("");
+       m_newHost = _T("");
+       m_newAdmin = TRUE;
+       m_startup = TRUE;
+
+       //{{AFX_DATA_INIT(CKrb4AddToRealmHostList)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CKrb4AddToRealmHostList::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4AddToRealmHostList)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4AddToRealmHostList, CDialog)
+       //{{AFX_MSG_MAP(CKrb4AddToRealmHostList)
+       ON_EN_CHANGE(IDC_EDIT_DEFAULT_REALM, OnChangeEditDefaultRealm)
+       ON_EN_CHANGE(IDC_EDIT_REALM_HOSTNAME, OnChangeEditRealmHostname)
+       ON_WM_SHOWWINDOW()
+       ON_BN_CLICKED(IDC_RADIO_ADMIN_SERVER, OnRadioAdminServer)
+       ON_BN_CLICKED(IDC_RADIO_NO_ADMIN_SERVER, OnRadioNoAdminServer)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToRealmHostList message handlers
+
+void CKrb4AddToRealmHostList::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+void CKrb4AddToRealmHostList::OnChangeEditDefaultRealm()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm);
+}
+
+void CKrb4AddToRealmHostList::OnChangeEditRealmHostname()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost);
+}
+
+void CKrb4AddToRealmHostList::OnRadioAdminServer()
+{
+       m_newAdmin = TRUE;
+}
+
+void CKrb4AddToRealmHostList::OnRadioNoAdminServer()
+{
+       m_newAdmin = FALSE;
+}
+
+void CKrb4AddToRealmHostList::OnOK()
+{
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+       m_newHost.TrimLeft();
+       m_newHost.TrimRight();
+
+       if (m_newRealm.IsEmpty() || m_newHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK::Both Realm and Host fields must be filled in!",
+                    "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' ') || -1 != m_newHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+
+       else
+         CDialog::OnOK(); // exit
+}
+
+BOOL CKrb4AddToRealmHostList::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_ADMIN_SERVER);
+
+       return TRUE;
+}
diff --git a/src/windows/leash/Krb4AddToRealmHostList.h b/src/windows/leash/Krb4AddToRealmHostList.h
new file mode 100644 (file)
index 0000000..1c81367
--- /dev/null
@@ -0,0 +1,75 @@
+//     **************************************************************************************
+//     File:                   Krb4AddToRealmHostList.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4AddToRealmHostList.cpp Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
+#define AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AddToRealmHostList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4AddToRealmHostList dialog
+
+class CKrb4AddToRealmHostList : public CDialog
+{
+// Construction
+       CString m_newRealm;
+       CString m_newHost;
+       BOOL m_newAdmin;
+       BOOL m_startup;
+
+public:
+       CKrb4AddToRealmHostList(CWnd* pParent = NULL);   // standard constructor
+
+       CString GetNewRealm() {return m_newRealm;}
+       CString GetNewHost() {return m_newHost;}
+       BOOL GetNewAdmin() {return m_newAdmin;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4AddToRealmHostList)
+       enum { IDD = IDD_KRB4_ADD_REALM };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4AddToRealmHostList)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4AddToRealmHostList)
+       afx_msg void OnChangeEditDefaultRealm();
+       afx_msg void OnChangeEditRealmHostname();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnRadioAdminServer();
+       afx_msg void OnRadioNoAdminServer();
+       virtual void OnOK();
+       virtual BOOL OnInitDialog();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb4DomainRealmMaintenance.cpp b/src/windows/leash/Krb4DomainRealmMaintenance.cpp
new file mode 100644 (file)
index 0000000..466b31a
--- /dev/null
@@ -0,0 +1,268 @@
+//     **************************************************************************************
+//     File:                   Krb4DomainRealmMaintenance.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4DomainRealmMaintenance.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbProperties.h"
+#include "Krb4Properties.h"
+#include "Krb4AddToDomainRealmList.h"
+#include "Krb4EditDomainRealmList.h"
+#include "Krb4DomainRealmMaintenance.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4DomainRealmMaintenance dialog
+
+
+IMPLEMENT_DYNCREATE(CKrb4DomainRealmMaintenance, CPropertyPage)
+
+CKrb4DomainRealmMaintenance::CKrb4DomainRealmMaintenance() :
+  CPropertyPage(CKrb4DomainRealmMaintenance ::IDD)
+{
+       m_defectiveLines = 0;
+}
+
+CKrb4DomainRealmMaintenance::~CKrb4DomainRealmMaintenance()
+{
+}
+
+void CKrb4DomainRealmMaintenance::DoDataExchange(CDataExchange* pDX)
+{
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4DomainRealmMaintenance)
+       DDX_Control(pDX, IDC_LIST_DOMAINREALM, m_realmDomainList);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4DomainRealmMaintenance, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrb4DomainRealmMaintenance)
+       ON_BN_CLICKED(IDC_BUTTON_REALM_HOST_ADD, OnButtonRealmHostAdd)
+       ON_BN_CLICKED(ID_BUTTON_REALM_HOST_REMOVE, OnButtonRealmHostRemove)
+       ON_BN_CLICKED(IDC_BUTTON_REALM_HOST_EDIT, OnButtonRealmHostEdit)
+       ON_LBN_SELCHANGE(IDC_LIST_DOMAINREALM, OnSelchangeListDomainrealm)
+       ON_LBN_DBLCLK(IDC_LIST_DOMAINREALM, OnDblclkListDomainrealm)
+       ON_BN_CLICKED(IDC_BUTTON_HOSTMAINT_HELP, OnButtonHostmaintHelp)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4DomainRealmMaintenance message handlers
+
+BOOL CKrb4DomainRealmMaintenance::OnApply()
+{
+       CStdioFile krbrealmCon;
+       if (!krbrealmCon.Open(CKrbProperties::m_krbrealmPath, CFile::modeCreate |
+                                                                                                                 CFile::modeNoTruncate |
+                                                                                                                 CFile::modeReadWrite))
+       {
+               LeashErrorBox("OnApply::Can't open Configuration File",
+                                         CKrbProperties::m_krbrealmPath);
+               return TRUE;
+       }
+
+       memset(lineBuf, '\0', sizeof(lineBuf));
+       krbrealmCon.SetLength(0);
+       krbrealmCon.WriteString(lineBuf);
+       for (INT maxItems = m_realmDomainList.GetCount(), item = 0; item < maxItems; item++)
+       {
+               memset(lineBuf, '\0', sizeof(lineBuf));
+               if (!m_realmDomainList.GetText(item, lineBuf))
+          break;
+
+               krbrealmCon.WriteString(lineBuf);
+               krbrealmCon.WriteString("\n");
+       }
+
+       krbrealmCon.Close();
+
+       return TRUE;
+}
+
+BOOL CKrb4DomainRealmMaintenance::OnInitDialog()
+{
+       CPropertyPage::OnInitDialog();
+       CStdioFile krbrealmCon;
+
+       if (!krbrealmCon.Open(CKrbProperties::m_krbrealmPath, CFile::modeReadWrite))
+       { // can't find file, so lets set some defaults
+               CString defaultStr;
+               defaultStr.Format("%s %s", "MIT.EDU", KRB_REALM);
+               m_realmDomainList.AddString(defaultStr);
+       }
+       else
+       {
+               while (TRUE)
+               {
+                       if (!krbrealmCon.ReadString(lineBuf, sizeof(lineBuf)))
+                         break;
+
+                       *(lineBuf + strlen(lineBuf) - 1) = 0;
+
+                       if (!strchr(lineBuf, ' ') && !strchr(lineBuf, '\t'))
+                       { // found a defective line
+                               m_defectiveLines++;
+                       }
+
+                       if (LB_ERR == m_realmDomainList.AddString(lineBuf))
+                       {
+                               LeashErrorBox("OnInitDialog::Can't read Configuration File",
+                                                         CKrbProperties::m_krbrealmPath);
+                               krbrealmCon.Close();
+                               return FALSE;
+                       }
+               }
+
+               krbrealmCon.Close();
+       }
+
+       m_realmDomainList.SetCurSel(0);
+
+       if (!m_realmDomainList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_REALM_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_REALM_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       return TRUE;
+}
+
+void CKrb4DomainRealmMaintenance::OnButtonRealmHostAdd()
+{
+       CKrb4AddToDomainRealmList addToDomainRealmList;
+       if (IDOK == addToDomainRealmList.DoModal())
+       {
+               if (addToDomainRealmList.GetNewRealm().IsEmpty())
+                 ASSERT(0);
+
+               CString newLine;
+               newLine = addToDomainRealmList.GetNewDomainHost() + " " + addToDomainRealmList.GetNewRealm();
+
+               // We don't want duplicate items in Listbox
+               CString ckDups;
+               for (INT item = 0; item < m_realmDomainList.GetCount(); item++)
+               {
+                       m_realmDomainList.GetText(item, ckDups);
+                       if (0 == ckDups.CompareNoCase(newLine))
+                       { // found duplicate item in Listbox
+                               LeashErrorBox("OnButtonRealmHostAdd::Found a Duplicate Item\nCan't add to List",
+                                                         ckDups);
+                               return;
+                       }
+               }
+
+               m_realmDomainList.InsertString(0, newLine);
+               m_realmDomainList.SetCurSel(0);
+               SetModified(TRUE);
+
+               if (1 == m_realmDomainList.GetCount())
+               {
+                       GetDlgItem(ID_BUTTON_REALM_HOST_REMOVE)->EnableWindow();GetDlgItem(IDC_BUTTON_REALM_HOST_EDIT)->EnableWindow();
+               }
+       }
+}
+
+void CKrb4DomainRealmMaintenance::OnButtonRealmHostRemove()
+{
+       if (IDYES != AfxMessageBox("Your about to remove an item from the list!\n\nContinue?",
+                                                          MB_YESNO))
+         return;
+
+       INT curSel = m_realmDomainList.GetCurSel();
+       m_realmDomainList.DeleteString(curSel);  // Single Sel Listbox
+
+       if (-1 == m_realmDomainList.SetCurSel(curSel))
+         m_realmDomainList.SetCurSel(curSel - 1);
+
+       if (!m_realmDomainList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_REALM_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_REALM_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       SetModified(TRUE);
+}
+
+void CKrb4DomainRealmMaintenance::OnButtonRealmHostEdit()
+{
+       INT selItemIndex = m_realmDomainList.GetCurSel();
+       LPSTR pSelItem = new char[m_realmDomainList.GetTextLen(selItemIndex) + 1];
+       if (!pSelItem)
+         ASSERT(0);
+
+       CString selItem;
+       m_realmDomainList.GetText(selItemIndex, selItem);
+       strcpy(pSelItem, selItem);
+
+       CKrb4EditDomainRealmList editDomainRealmList(pSelItem);
+       delete [] pSelItem;
+
+       if (IDOK == editDomainRealmList.DoModal())
+       {
+               CString editedItem = editDomainRealmList.GetEditedItem();
+               if (0 != selItem.CompareNoCase(editedItem) &&
+                       LB_ERR != m_realmDomainList.FindStringExact(-1, editedItem))
+               {
+                       LeashErrorBox("OnButtonRealmHostEdit::Found a Duplicate!\nCan't add to List",
+                                                         editedItem);
+
+                       return;
+               }
+
+               m_realmDomainList.DeleteString(selItemIndex);
+               m_realmDomainList.InsertString(selItemIndex, editDomainRealmList.GetEditedItem());
+               m_realmDomainList.SetCurSel(selItemIndex);
+               SetModified(TRUE);
+       }
+}
+
+void CKrb4DomainRealmMaintenance::OnSelchangeListDomainrealm()
+{
+       //SetModified(TRUE);
+}
+
+void CKrb4DomainRealmMaintenance::OnDblclkListDomainrealm()
+{
+       OnButtonRealmHostEdit();
+}
+
+BOOL CKrb4DomainRealmMaintenance::PreTranslateMessage(MSG* pMsg)
+{
+       if (m_defectiveLines)
+       {
+               if (m_defectiveLines == 1)
+                 LeashErrorBox("Found a defective entry in file",
+                                               CKrbProperties::m_krbrealmPath, "Warning");
+           else if (m_defectiveLines > 1)
+             LeashErrorBox("Found more then one defective entry in file",
+                                               CKrbProperties::m_krbrealmPath, "Warning");
+       }
+
+       m_defectiveLines = 0;
+       return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+
+
+
+void CKrb4DomainRealmMaintenance::OnButtonHostmaintHelp()
+{
+       MessageBox("No Help Available!", "Leash", MB_OK);
+}
diff --git a/src/windows/leash/Krb4DomainRealmMaintenance.h b/src/windows/leash/Krb4DomainRealmMaintenance.h
new file mode 100644 (file)
index 0000000..6bdba77
--- /dev/null
@@ -0,0 +1,76 @@
+//     **************************************************************************************
+//     File:                   Krb4DomainRealmMaintenance.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4DomainRealmMaintenance.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_REALMNAMEMAINTENANCE_H__9CA36918_8FC0_11D2_94CC_0000861B8A3C__INCLUDED_)
+#define AFX_REALMNAMEMAINTENANCE_H__9CA36918_8FC0_11D2_94CC_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// RealmNameMaintenance.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4DomainRealmMaintenance dialog
+
+class CKrb4DomainRealmMaintenance : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrb4DomainRealmMaintenance)
+       CHAR lineBuf[MAXLINE];
+       INT m_defectiveLines;
+
+public:
+       CKrb4DomainRealmMaintenance();   // standard constructor
+       virtual ~CKrb4DomainRealmMaintenance();
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4DomainRealmMaintenance)
+       enum { IDD = IDD_KRB4_DOMAINREALM_MAINT };
+       CDragListBox m_realmDomainList;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4DomainRealmMaintenance)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4DomainRealmMaintenance)
+       virtual BOOL OnInitDialog();
+       virtual BOOL OnApply();
+       afx_msg void OnButtonRealmHostAdd();
+       afx_msg void OnButtonRealmHostRemove();
+       afx_msg void OnButtonRealmHostEdit();
+       afx_msg void OnSelchangeListDomainrealm();
+       afx_msg void OnDblclkListDomainrealm();
+       afx_msg void OnButtonHostmaintHelp();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_REALMNAMEMAINTENANCE_H__9CA36918_8FC0_11D2_94CC_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb4EditDomainRealmList.cpp b/src/windows/leash/Krb4EditDomainRealmList.cpp
new file mode 100644 (file)
index 0000000..0470448
--- /dev/null
@@ -0,0 +1,147 @@
+//     **************************************************************************************
+//     File:                   Krb4EditDomainRealmList.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4EditDomainRealmList.h. Contains variables and functions
+//                                     for Kerberos Four Properites
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4Properties.h"
+#include "Krb4EditDomainRealmList.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditDomainRealmList dialog
+
+
+CKrb4EditDomainRealmList::CKrb4EditDomainRealmList(LPSTR editItem, CWnd* pParent)
+       : CDialog(CKrb4EditDomainRealmList::IDD, pParent)
+{
+    m_startup = TRUE;
+       m_editItem = _T("");
+
+       // Parse the passed in item
+       LPSTR pEditItem = editItem;
+       LPSTR findSpace = strchr(editItem, ' ');
+       if (findSpace)
+         *findSpace = 0;
+       else
+       {
+                LeashErrorBox("This is a defective entry in file",
+                                          CKrb4ConfigFileLocation::m_newKrbrealmFile);
+                ASSERT(0);
+                m_initDomainHost = m_newDomainHost = editItem;
+                m_initRealm = m_newRealm = _T("");
+                return;
+       }
+
+       m_initDomainHost = m_newDomainHost = editItem;  // first token
+
+       pEditItem = strchr(editItem, '\0');
+       if (pEditItem)
+       {
+               pEditItem++;
+               findSpace++;
+       }
+       else
+         ASSERT(0);
+
+       findSpace = strchr(pEditItem, ' ');
+       if (findSpace)
+       {
+               *findSpace = 0;
+       }
+
+       m_initRealm = m_newRealm = pEditItem; // second token
+
+       //{{AFX_DATA_INIT(CKrb4EditDomainRealmList)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+void CKrb4EditDomainRealmList::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4EditDomainRealmList)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4EditDomainRealmList, CDialog)
+       //{{AFX_MSG_MAP(CKrb4EditDomainRealmList)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_REALMNAME, OnChangeEditDefaultRealm)
+       ON_EN_CHANGE(IDC_EDIT_DOMAINHOST, OnChangeEditRealmHostname)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditDomainRealmList message handlers
+
+
+void CKrb4EditDomainRealmList::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+BOOL CKrb4EditDomainRealmList::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       SetDlgItemText(IDC_EDIT_REALMNAME, m_newRealm);
+       SetDlgItemText(IDC_EDIT_DOMAINHOST, m_newDomainHost);
+
+       return TRUE;
+}
+
+void CKrb4EditDomainRealmList::OnChangeEditDefaultRealm()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_REALMNAME, m_newRealm);
+}
+
+void CKrb4EditDomainRealmList::OnChangeEditRealmHostname()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_DOMAINHOST, m_newDomainHost);
+}
+
+void CKrb4EditDomainRealmList::OnOK()
+{
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+       m_newDomainHost.TrimLeft();
+       m_newDomainHost.TrimRight();
+
+       if (m_newRealm.IsEmpty() || m_newDomainHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK::Both Domain-Host and Realm fields must be filled in!",
+                    "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' ') || -1 != m_newDomainHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+
+       else
+         CDialog::OnOK(); // exit
+
+       m_editItem = m_newDomainHost + " " + m_newRealm;
+}
diff --git a/src/windows/leash/Krb4EditDomainRealmList.h b/src/windows/leash/Krb4EditDomainRealmList.h
new file mode 100644 (file)
index 0000000..9f8a18f
--- /dev/null
@@ -0,0 +1,77 @@
+//     **************************************************************************************
+//     File:                   Krb4EditDomainRealmList.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4EditDomainRealmList.cpp. Contains variables and functions
+//                                     for Kerberos Four Properites
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_KRB4EDITDOMAINREALMLIST_H__F4D41684_96A4_11D2_94E2_0000861B8A3C__INCLUDED_)
+#define AFX_KRB4EDITDOMAINREALMLIST_H__F4D41684_96A4_11D2_94E2_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// CKrb4EditDomainRealmList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditDomainRealmList dialog
+
+class CKrb4EditDomainRealmList : public CDialog
+{
+// Construction
+private:
+       CString m_editItem;
+       CString m_initRealm;
+       CString m_newRealm;
+       CString m_initDomainHost;
+       CString m_newDomainHost;
+       BOOL m_startup;
+
+
+public:
+       CKrb4EditDomainRealmList(LPSTR editItem, CWnd* pParent = NULL);
+       CString GetEditedItem() {return m_editItem;}
+       CString GetRealm() {return m_newRealm;}
+       CString GetDomainHost() {return m_newDomainHost;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4EditDomainRealmList)
+       enum { IDD = IDD_KRB4_EDIT_DOMAINREALMNAME };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4EditDomainRealmList)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4EditDomainRealmList)
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       virtual BOOL OnInitDialog();
+       afx_msg void OnChangeEditDefaultRealm();
+       afx_msg void OnChangeEditRealmHostname();
+       virtual void OnOK();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRB4EDITDOMAINREALMLIST_H__F4D41684_96A4_11D2_94E2_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb4EditRealmHostList.cpp b/src/windows/leash/Krb4EditRealmHostList.cpp
new file mode 100644 (file)
index 0000000..840f626
--- /dev/null
@@ -0,0 +1,193 @@
+//     **************************************************************************************
+//     File:                   Krb4EditRealmHostList.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4EditRealmHostList.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4Properties.h"
+#include "Krb4EditRealmHostList.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditRealmHostList dialog
+
+CKrb4EditRealmHostList::CKrb4EditRealmHostList(LPSTR editItem, CWnd* pParent)
+       : CDialog(CKrb4EditRealmHostList::IDD, pParent)
+{
+       m_startup = TRUE;
+       m_editItem = _T("");
+
+/*
+    // Parse the passed in item
+       LPSTR pEditItem = editItem;
+       LPSTR findSpace = strchr(editItem, ' ');
+       if (findSpace)
+         *findSpace = 0;
+       else
+       {
+                LeashErrorBox("This is a defective entry in file",
+                                          CKrb4ConfigFileLocation::m_krbFile);
+                ASSERT(0);
+                m_initRealm = m_newRealm = editItem;
+                m_initHost = m_newHost = _T("");
+       }
+
+       m_initRealm = m_newRealm = editItem;  // first token
+
+       pEditItem = strchr(editItem, '\0');
+       if (pEditItem)
+       {
+               pEditItem++;
+               findSpace++;
+       }
+       else
+         ASSERT(0);
+
+       findSpace = strchr(pEditItem, ' ');
+       if (findSpace)
+       {
+               *findSpace = 0;
+       }
+       else
+       {
+               m_initAdmin = m_newAdmin = FALSE;
+               m_initHost = m_newHost = pEditItem; // second token
+               return;
+       }
+
+       m_initHost = m_newHost = pEditItem; // second token
+
+       findSpace++;
+       pEditItem = findSpace;
+       if (pEditItem)
+       {
+               if (strstr(pEditItem, "admin server"))
+                 m_initAdmin = m_newAdmin = TRUE;
+               //else
+                 //;  It must be something else??? :(
+       }
+       else
+         ASSERT(0);
+*/
+       //{{AFX_DATA_INIT(CKrb4EditRealmHostList)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+void CKrb4EditRealmHostList::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4EditRealmHostList)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4EditRealmHostList, CDialog)
+       //{{AFX_MSG_MAP(CKrb4EditRealmHostList)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_DEFAULT_REALM, OnChangeEditDefaultRealm)
+       ON_EN_CHANGE(IDC_EDIT_REALM_HOSTNAME, OnChangeEditRealmHostname)
+       ON_BN_CLICKED(IDC_RADIO_ADMIN_SERVER, OnRadioAdminServer)
+       ON_BN_CLICKED(IDC_RADIO_NO_ADMIN_SERVER, OnRadioNoAdminServer)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditRealmHostList message handlers
+
+BOOL CKrb4EditRealmHostList::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       SetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm);
+       SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost);
+
+       if (m_initAdmin)
+       { // has Admin Server
+               CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_ADMIN_SERVER);
+       }
+       else
+       { // no Admin Server
+               CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER);
+       }
+
+       //GetDlgItem(IDC_EDIT_DEFAULT_REALM)->EnableWindow();
+       //GetDlgItem(IDC_EDIT_DEFAULT_REALM)->SetFocus();
+
+       return TRUE;
+}
+
+void CKrb4EditRealmHostList::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+void CKrb4EditRealmHostList::OnChangeEditDefaultRealm()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm);
+}
+
+void CKrb4EditRealmHostList::OnChangeEditRealmHostname()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost);
+}
+
+void CKrb4EditRealmHostList::OnRadioAdminServer()
+{
+       m_newAdmin = TRUE;
+}
+
+void CKrb4EditRealmHostList::OnRadioNoAdminServer()
+{
+       m_newAdmin = FALSE;
+}
+
+void CKrb4EditRealmHostList::OnOK()
+{
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+       m_newHost.TrimLeft();
+       m_newHost.TrimRight();
+
+       if (m_newRealm.IsEmpty() || m_newHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK::Both Realm and Host fields must be filled in!",
+                    "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' ') || -1 != m_newHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+
+       else
+         CDialog::OnOK(); // exit
+
+       m_editItem = m_newRealm + " " + m_newHost;
+
+       if (m_newAdmin)
+       {
+               m_editItem += " ";
+               m_editItem += ADMIN_SERVER;
+       }
+}
diff --git a/src/windows/leash/Krb4EditRealmHostList.h b/src/windows/leash/Krb4EditRealmHostList.h
new file mode 100644 (file)
index 0000000..5ed3864
--- /dev/null
@@ -0,0 +1,79 @@
+//     **************************************************************************************
+//     File:                   Krb4EditRealmHostList.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4EditRealmHostList.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#if !defined(AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
+#define AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EditRealmHostList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4EditRealmHostList dialog
+
+class CKrb4EditRealmHostList : public CDialog
+{
+// Construction
+private:
+       CString m_editItem;
+       CString m_initRealm;
+       CString m_newRealm;
+       CString m_initHost;
+       CString m_newHost;
+       BOOL m_initAdmin;
+       BOOL m_newAdmin;
+       BOOL m_startup;
+
+public:
+       CKrb4EditRealmHostList(LPSTR editItem, CWnd* pParent = NULL);
+       CString GetEditedItem() {return m_editItem;}
+       CString GetNewRealm() {return m_newRealm;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4EditRealmHostList)
+       enum { IDD = IDD_KRB4_EDIT_REALM };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4EditRealmHostList)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4EditRealmHostList)
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnChangeEditDefaultRealm();
+       afx_msg void OnChangeEditRealmHostname();
+       afx_msg void OnRadioAdminServer();
+       afx_msg void OnRadioNoAdminServer();
+       virtual void OnOK();
+       virtual BOOL OnInitDialog();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb4Properties.cpp b/src/windows/leash/Krb4Properties.cpp
new file mode 100644 (file)
index 0000000..a26d585
--- /dev/null
@@ -0,0 +1,390 @@
+//     **************************************************************************************
+//     File:                   Krb4Properties.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbProperties.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#include "stdafx.h"
+#include "Leash.h"
+#include "Krb4Properties.h"
+#include "LeashFileDialog.h"
+#include "LeashMessageBox.h"
+#include "wshelper.h"
+#include "lglobals.h"
+#include <io.h>
+#include <direct.h>
+#include "reminder.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+///////////////////////////////////////////////////////////////////////
+// CKrb4ConfigFileLocation property page
+
+IMPLEMENT_DYNCREATE(CKrb4ConfigFileLocation, CPropertyPage)
+
+CString CKrb4ConfigFileLocation::m_newKrbFile;
+CString CKrb4ConfigFileLocation::m_newKrbrealmFile;
+
+CKrb4ConfigFileLocation::CKrb4ConfigFileLocation() : CPropertyPage(CKrb4ConfigFileLocation::IDD)
+{
+    m_newTicketFile = _T("");
+    m_newKrbFile = _T("");
+    m_newKrbrealmFile = _T("");
+    m_initKrbFile = _T("");
+    m_initKrbrealmFile = _T("");
+    m_initTicketFile = _T("");
+    m_noKrbrealmFileStartupWarning = FALSE;
+    m_noKrbFileStartupWarning = FALSE;
+
+    m_startupPage1 = TRUE;
+
+       //{{AFX_DATA_INIT(CKrb4ConfigFileLocation)
+       //}}AFX_DATA_INIT
+}
+
+CKrb4ConfigFileLocation::~CKrb4ConfigFileLocation()
+{
+}
+
+BOOL CKrb4ConfigFileLocation::OnInitDialog()
+{
+       CPropertyPage::OnInitDialog();
+
+       INT krbCreate = 0;
+       INT krbrealmCreate = 0;
+    CHAR krb_path[MAX_PATH];
+       CHAR krbrealm_path[MAX_PATH];
+    CHAR ticketName[MAX_PATH];
+       unsigned int krb_path_sz = sizeof(krb_path);
+    unsigned int krbrealm_path_sz = sizeof(krbrealm_path);
+    CString strMessage;
+
+
+       // Set KRB.CON
+       memset(krb_path, '\0', sizeof(krb_path));
+       if (!pkrb_get_krbconf2(krb_path, &krb_path_sz))
+       { // Error has happened
+               m_noKrbFileStartupWarning = TRUE;
+       }
+       else
+       { // normal find
+               m_initKrbFile = krb_path;
+           m_newKrbFile = m_initKrbFile;
+        SetDlgItemText(IDC_EDIT_KRB_LOC, m_initKrbFile);
+    }
+
+    // Set KRBREALM.CON
+    memset(krbrealm_path, '\0', sizeof(krbrealm_path));
+    if (!pkrb_get_krbrealm2(krbrealm_path, &krbrealm_path_sz))
+       {
+        // Error has happened
+               m_noKrbrealmFileStartupWarning = TRUE;
+       }
+       else
+       {
+        // normal find
+               m_initKrbrealmFile = krbrealm_path;
+        m_newKrbrealmFile = m_initKrbrealmFile;
+        SetDlgItemText(IDC_EDIT_KRBREALM_LOC, m_initKrbrealmFile);
+    }
+
+       if (pLeash_get_lock_file_locations() ||
+        getenv("KRB4_KRB.REALMS") || getenv("KRB4_KRB.CONF") || getenv("KRB4_CONFIG"))
+    {
+        GetDlgItem(IDC_EDIT_KRB_LOC)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_KRBREALM_LOC)->EnableWindow(FALSE);
+        GetDlgItem(IDC_BUTTON_KRB_BROWSE)->EnableWindow(FALSE);
+        GetDlgItem(IDC_BUTTON_KRBREALM_BROWSE)->EnableWindow(FALSE);
+    }
+    else if ( !(getenv("KRB4_KRB.REALMS") || getenv("KRB4_KRB.CONF") || getenv("KRB4_CONFIG")) )
+    {
+        GetDlgItem(IDC_STATIC_CONFILES)->ShowWindow(FALSE);
+    }
+
+
+    // Set TICKET.KRB file Editbox
+    *ticketName = NULL;
+       pkrb_set_tkt_string(0);
+
+    char *pticketName = ptkt_string();
+    if (pticketName)
+        strcpy(ticketName, pticketName);
+
+    if (!*ticketName)
+       {
+               LeashErrorBox("OnInitDialog::Can't locate ticket file", TICKET_FILE);
+       }
+       else
+       {
+        m_initTicketFile = m_newTicketFile = ticketName;
+               m_ticketEditBox.ReplaceSel(m_initTicketFile);
+       }
+
+       if (getenv("KRBTKFILE"))
+        GetDlgItem(IDC_EDIT_TICKET_FILE)->EnableWindow(FALSE);
+    else
+        GetDlgItem(IDC_STATIC_TXT)->ShowWindow(FALSE);
+
+    return FALSE;
+}
+
+BOOL CKrb4ConfigFileLocation::OnApply()
+{
+       // Krb.con
+    if (0 != m_initKrbFile.CompareNoCase(m_newKrbFile))
+    {
+        // Commit changes
+        if (SetRegistryVariable("krb.conf", m_newKrbFile,
+            "Software\\MIT\\Kerberos4"))
+        {
+            MessageBox("Failed to set \"Krb.conf\"!", "Error", MB_OK);
+        }
+
+        m_initKrbFile = m_newKrbFile;
+    }
+
+    // Krbrealms.con
+    if (0 != m_initKrbrealmFile.CompareNoCase(m_newKrbrealmFile))
+    {
+        // Commit changes
+        if (SetRegistryVariable("krb.realms", m_newKrbrealmFile,
+            "Software\\MIT\\Kerberos4"))
+        {
+            MessageBox("Failed to set \"krb.realms\"!", "Error", MB_OK);
+        }
+
+        m_initKrbrealmFile = m_newKrbrealmFile;
+    }
+
+    // Ticket file
+       if (0 != m_initTicketFile.CompareNoCase(m_newTicketFile))
+       {
+        if (getenv("KRBTKFILE"))
+        {
+            // Just in case they set (somehow) KRBTKFILE while this box is up
+            MessageBox("OnApply::Ticket file is set in your System's\
+                        Environment!\nYou must first remove it.",
+                        "Error", MB_OK);
+
+            return TRUE;
+        }
+
+        // Commit changes
+        if (SetRegistryVariable("ticketfile", m_newTicketFile,
+            "Software\\MIT\\Kerberos4"))
+        {
+            MessageBox("Failed to set \"ticketfile\"!", "Error", MB_OK);
+        }
+
+        m_initTicketFile = m_newTicketFile;
+       }
+
+    return TRUE;
+}
+
+VOID CKrb4ConfigFileLocation::OnOK()
+{
+       CPropertyPage::OnOK();
+}
+
+VOID CKrb4ConfigFileLocation::DoDataExchange(CDataExchange* pDX)
+{
+       TRACE("Entering CKrb4ConfigFileLocation::DoDataExchange -- %d\n",
+             pDX->m_bSaveAndValidate);
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4ConfigFileLocation)
+       DDX_Control(pDX, IDC_EDIT_TICKET_FILE, m_ticketEditBox);
+       //}}AFX_DATA_MAP
+}
+
+
+VOID CKrb4ConfigFileLocation::OnButtonKrbBrowse()
+{
+       CString msg;
+       msg.Format("Select %s Location", KRB_FILE);
+
+    CString krb_path = "*.*";
+       CLeashFileDialog dlgFile(TRUE, NULL, krb_path, "Kerbereos Four Config. File (.con)");
+    dlgFile.m_ofn.lpstrTitle = msg;
+
+    if (IDOK == dlgFile.DoModal())
+       {
+               //m_newKrbFile = dlgFile.GetSelectedFileName();
+        m_newKrbFile= dlgFile.GetPathName();
+               SetDlgItemText(IDC_EDIT_KRB_LOC, m_newKrbFile);
+        SetModified(TRUE);
+    }
+}
+
+VOID CKrb4ConfigFileLocation::OnButtonKrbrealmBrowse()
+{
+       CString msg;
+       msg.Format("Select %s Location", KRBREALM_FILE);
+
+    CString krbrealm_path = "*.*";
+    CLeashFileDialog dlgFile(TRUE, NULL, krbrealm_path, "Kerbereos Four Config. File (.con)");
+    dlgFile.m_ofn.lpstrTitle = msg;
+
+    if (IDOK == dlgFile.DoModal())
+       {
+               //m_krbrealmFile = dlgFile.GetSelectedFileName();
+               m_newKrbrealmFile = dlgFile.GetPathName();
+               SetDlgItemText(IDC_EDIT_KRB_KRBREALM_LOC, m_newKrbrealmFile);
+        SetModified(TRUE);
+    }
+}
+
+/*
+VOID CKrb4ConfigFileLocation::OnButtonTicketfileBrowse()
+{
+       CString ticketPath = *.*";
+       CLeashFileDialog dlgFile(TRUE, NULL, ticketPath, "Kerberos Four Ticket File (.con)");
+       CString msg;
+       msg.Format("Select Location/Ticket File (Default file = %s)", TICKET_FILE);
+       dlgFile.m_ofn.lpstrTitle = msg;
+       while (TRUE)
+       {
+               if (IDOK == dlgFile.DoModal())
+               {
+                       m_newTicketFile = dlgFile.GetPathName();
+                       SetDlgItemText(IDC_EDIT_TICKET_FILE, m_newTicketFile);
+                       SetModified(TRUE);
+                       break;
+               }
+               else
+                 break;
+       }
+}
+*/
+
+void CKrb4ConfigFileLocation::OnChangeEditKrbLoc()
+{
+       if (!m_startupPage1)
+       {
+               GetDlgItemText(IDC_EDIT_KRB_LOC, m_newKrbFile);
+               SetModified(TRUE);
+       }
+}
+
+void CKrb4ConfigFileLocation::OnChangeEditKrbrealmLoc()
+{
+       if (!m_startupPage1)
+       {
+               GetDlgItemText(IDC_EDIT_KRBREALM_LOC, m_newKrbrealmFile);
+               SetModified(TRUE);
+       }
+}
+
+void CKrb4ConfigFileLocation::OnChangeEditTicketFile()
+{
+       if (!m_startupPage1)
+       {
+               GetDlgItemText(IDC_EDIT_TICKET_FILE, m_newTicketFile);
+               SetModified(TRUE);
+       }
+}
+
+VOID CKrb4ConfigFileLocation::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+    CPropertyPage::OnShowWindow(bShow, nStatus);
+}
+
+VOID CKrb4ConfigFileLocation::OnCancel()
+{
+       CPropertyPage::OnCancel();
+}
+
+void CKrb4ConfigFileLocation::OnHelp()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_KRB4_PROPERTIES_COMMAND);
+#else
+    AfxGetApp()->WinHelp(HID_KRB4_PROPERTIES_COMMAND);
+#endif
+}
+
+BOOL CKrb4ConfigFileLocation::PreTranslateMessage(MSG* pMsg)
+{
+       // TODO: Add your specialized code here and/or call the base class
+       CString wmsg;
+       if (m_startupPage1)
+       {
+        if (m_noKrbFileStartupWarning)
+               {
+                       wmsg.Format("OnInitDialog::Can't locate configuration file: %s.",
+                                                         KRB_FILE);
+                       MessageBox(wmsg, "Leash", MB_OK);
+            m_noKrbFileStartupWarning  = FALSE;
+               }
+
+        if (m_noKrbrealmFileStartupWarning)
+               {
+                       wmsg.Format("OnInitDialog::Can't locate configuration file: %s.",
+                                                         KRBREALM_FILE);
+                       MessageBox(wmsg, "Leash", MB_OK);
+            m_noKrbrealmFileStartupWarning = FALSE;
+        }
+    }
+
+       m_startupPage1 = FALSE;
+    return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4ConfigFileLocation, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrb4ConfigFileLocation)
+       ON_BN_CLICKED(IDC_BUTTON_KRB_BROWSE, OnButtonKrbBrowse)
+       ON_BN_CLICKED(IDC_BUTTON_KRBREALM_BROWSE, OnButtonKrbrealmBrowse)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_TICKET_FILE, OnChangeEditTicketFile)
+    ON_COMMAND(ID_HELP, OnHelp)
+       ON_EN_CHANGE(IDC_EDIT_KRB_LOC, OnChangeEditKrbLoc)
+       ON_EN_CHANGE(IDC_EDIT_KRBREALM_LOC, OnChangeEditKrbrealmLoc)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+///////////////////////////////////////////////////////////////////////
+// CKrb4Properties
+
+IMPLEMENT_DYNAMIC(CKrb4Properties, CPropertySheet)
+CKrb4Properties::CKrb4Properties(UINT nIDCaption, CWnd* pParentWnd,
+                                 UINT iSelectPage)
+:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+{
+}
+
+CKrb4Properties::CKrb4Properties(LPCTSTR pszCaption, CWnd* pParentWnd,
+                                                                UINT iSelectPage)
+:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+{
+       AddPage(&m_fileLocation);
+}
+
+CKrb4Properties::~CKrb4Properties()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4Properties, CPropertySheet)
+       //{{AFX_MSG_MAP(CKrb4Properties)
+               // NOTE - the ClassWizard will add and remove mapping macros here.
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+///////////////////////////////////////////////////////////////////////
+// CKrb4Properties message handlers
diff --git a/src/windows/leash/Krb4Properties.h b/src/windows/leash/Krb4Properties.h
new file mode 100644 (file)
index 0000000..016badc
--- /dev/null
@@ -0,0 +1,138 @@
+//     **************************************************************************************
+//     File:                   Krb4Properties.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbProperties.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
+#define AFX_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+// Krb4Properties.h : header file
+//
+
+#include "Resource.h"
+//#include "Krb4RealmHostMaintenance.h"
+//#include "Krb4DomainRealmMaintenance.h"
+
+///////////////////////////////////////////////////////////////////////
+// CKrb4ConfigFileLocation dialog
+
+class CKrb4ConfigFileLocation : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrb4ConfigFileLocation)
+       CString m_ticketFile;
+       CString m_newTicketFile;
+       static CString m_newKrbFile;
+    static CString m_newKrbrealmFile; // static for the CKrb4EditDomainRealmList class
+    CString m_initKrbFile;
+    CString m_initKrbrealmFile;
+    CString m_initTicketFile;
+
+       BOOL m_noKrbFileStartupWarning;
+    BOOL m_noKrbrealmFileStartupWarning;
+       BOOL m_startupPage1;
+
+public:
+       CKrb4ConfigFileLocation();
+       ~CKrb4ConfigFileLocation();
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4ConfigFileLocation)
+       enum { IDD = IDD_KRB4_PROP_LOCATION };
+       CEdit   m_ticketEditBox;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generate virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4ConfigFileLocation)
+       public:
+       virtual VOID OnCancel();
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual VOID DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       virtual VOID OnOK();
+       virtual BOOL OnApply();
+
+// Implementation
+protected:
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4ConfigFileLocation)
+       virtual BOOL OnInitDialog();
+       afx_msg VOID OnButtonKrbBrowse();
+       afx_msg VOID OnButtonKrbrealmBrowse();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnChangeEditTicketFile();
+    afx_msg void OnHelp();
+       afx_msg void OnChangeEditKrbLoc();
+       afx_msg void OnChangeEditKrbrealmLoc();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+
+};
+
+
+//////////////////////////////////////////////////////////////////////
+// CKrb4Properties
+
+class CKrb4Properties : public CPropertySheet
+{
+private:
+       DECLARE_DYNAMIC(CKrb4Properties)
+
+public:
+       CKrb4ConfigFileLocation m_fileLocation;
+
+       static BOOL applyButtonEnabled;
+
+// Construction
+public:
+       CKrb4Properties(UINT nIDCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+       CKrb4Properties(LPCTSTR pszCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4Properties)
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CKrb4Properties();
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CKrb4Properties)
+               // NOTE - the ClassWizard will add and remove member functions here.
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/Krb4RealmHostMaintenance.cpp b/src/windows/leash/Krb4RealmHostMaintenance.cpp
new file mode 100644 (file)
index 0000000..7e8ad4f
--- /dev/null
@@ -0,0 +1,373 @@
+//     **************************************************************************************
+//     File:                   Krb4RealmHostMaintenance.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for Krb4RealmHostMaintenance.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbProperties.h"
+#include "Krb4Properties.h"
+#include "Krb4AddToRealmHostList.h"
+#include "Krb4RealmHostMaintenance.h"
+#include "Krb4EditRealmHostList.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4RealmHostMaintenance dialog
+
+
+IMPLEMENT_DYNCREATE(CKrb4RealmHostMaintenance, CPropertyPage)
+
+CKrb4RealmHostMaintenance::CKrb4RealmHostMaintenance() : CPropertyPage(CKrb4RealmHostMaintenance::IDD)
+{
+       m_defectiveLines = 0;
+    m_initDnsKdcLookup = m_newDnsKdcLookup = 0;
+}
+
+CKrb4RealmHostMaintenance::~CKrb4RealmHostMaintenance()
+{
+}
+
+void CKrb4RealmHostMaintenance::DoDataExchange(CDataExchange* pDX)
+{
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrb4RealmHostMaintenance)
+       DDX_Control(pDX, IDC_LIST_KRB4_REALM_HOST, m_RealmHostList);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb4RealmHostMaintenance, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrb4RealmHostMaintenance)
+       ON_BN_CLICKED(IDC_BUTTON_KRB4_REALM_HOST_ADD, OnButtonRealmHostAdd)
+       ON_BN_CLICKED(IDC_BUTTON_KRB4_REALM_HOST_EDIT, OnButtonRealmHostEdit)
+       ON_BN_CLICKED(ID_BUTTON_KRB4_REALM_HOST_REMOVE, OnButtonRealmHostRemove)
+       ON_LBN_SELCHANGE(IDC_LIST_KRB4_REALM_HOST, OnSelchangeListRemoveHost)
+       ON_LBN_DBLCLK(IDC_LIST_KRB4_REALM_HOST, OnDblclkListRemoveHost)
+       ON_BN_CLICKED(IDC_BUTTON_REALMHOST_MAINT_HELP2, OnButtonRealmhostMaintHelp2)
+    ON_BN_CLICKED(IDC_KRB4_DNS_KDC, OnCheckDnsKdcLookup)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4RealmHostMaintenance message handlers
+
+BOOL CKrb4RealmHostMaintenance::OnInitDialog()
+{
+       CPropertyPage::OnInitDialog();
+
+       CStdioFile krbCon;
+       if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeReadWrite))
+       { // can't find file, so lets set some defaults
+
+               m_RealmHostList.AddString(KRB_REALM     " " KRB_MASTER);
+       }
+       else
+       {
+               memset(lineBuf, '\0', sizeof(lineBuf));
+               krbCon.ReadString(lineBuf, sizeof(lineBuf));
+               while (TRUE)
+               {
+                       if (!krbCon.ReadString(lineBuf, sizeof(lineBuf)))
+                         break;
+
+                       *(lineBuf + strlen(lineBuf) - 1) = 0;
+
+                       if (!strchr(lineBuf, ' ') && !strchr(lineBuf, '\t'))
+                       { // found a defective line
+                               m_defectiveLines++;
+                       }
+
+            if ( !strncmp(".KERBEROS.OPTION.",lineBuf,17) ) {
+                char * p = &lineBuf[17];
+                while (isspace(*p))
+                    p++;
+                if (!strcmp("dns",p))
+                    m_initDnsKdcLookup = m_newDnsKdcLookup = 1;
+            } else {
+                if (LB_ERR == m_RealmHostList.AddString(lineBuf))
+                {
+                    LeashErrorBox("OnInitDialog::Can't read Configuration File",
+                                   CKrbProperties::m_krbPath);
+                    krbCon.Close();
+                    return FALSE;
+                }
+            }
+               }
+
+               krbCon.Close();
+       }
+
+       m_RealmHostList.SetCurSel(0);
+
+       if (!m_RealmHostList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_KRB4_REALM_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_KRB4_REALM_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       return TRUE;
+}
+
+BOOL CKrb4RealmHostMaintenance::OnApply()
+{
+       CStdioFile krbCon;
+       if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeCreate |
+                                                                                                                CFile::modeNoTruncate |
+                                                                                                                CFile::modeReadWrite))
+       {
+               LeashErrorBox("OnApply::Can't open Configuration File",
+                                         CKrbProperties::m_krbPath);
+               return TRUE;
+       }
+
+       memset(lineBuf, '\0', sizeof(lineBuf));
+       if (!krbCon.ReadString(lineBuf, sizeof(lineBuf)))
+       {
+//-----ADL----///strcpy(lineBuf, CKrb4ConfigOptions::m_newDefaultRealm);
+               strcat(lineBuf, "\n");
+       }
+
+       krbCon.SetLength(0);
+       krbCon.WriteString(lineBuf);
+       for (INT maxItems = m_RealmHostList.GetCount(), item = 0; item < maxItems; item++)
+       {
+               memset(lineBuf, '\0', sizeof(lineBuf));
+               if (!m_RealmHostList.GetText(item, lineBuf))
+          break;
+
+               krbCon.WriteString(lineBuf);
+               krbCon.WriteString("\n");
+       }
+
+    if ( m_newDnsKdcLookup )
+        krbCon.WriteString(".KERBEROS.OPTION. dns\n");
+
+       krbCon.Close();
+       return TRUE;
+}
+
+void CKrb4RealmHostMaintenance::OnOK()
+{
+       CPropertyPage::OnOK();
+}
+
+void CKrb4RealmHostMaintenance::OnCancel()
+{
+       CPropertyPage::OnCancel();
+}
+
+void CKrb4RealmHostMaintenance::OnCheckDnsKdcLookup()
+{
+    m_newDnsKdcLookup = (BOOL)IsDlgButtonChecked(IDC_KRB4_DNS_KDC);
+    SetModified(TRUE);
+}
+
+void CKrb4RealmHostMaintenance::ResetDefaultRealmComboBox()
+{ // krb4 is loaded without krb5
+       CHAR lineBuf[REALM_SZ + MAX_HSTNM + 20];
+
+       int maxItems = m_RealmHostList.GetCount();
+
+       CKrbConfigOptions::m_krbRealmEditbox.ResetContent();
+
+       for (int xItems = 0; xItems < maxItems; xItems++)
+       {
+               m_RealmHostList.GetText(xItems, lineBuf);
+
+               LPSTR space = strchr(lineBuf, ' ');
+               if (space)
+                 *space = 0;
+               else
+                 ASSERT(0);
+
+               if (CB_ERR == CKrbConfigOptions::m_krbRealmEditbox.FindStringExact(-1, lineBuf))
+               { // no dups
+                       if (LB_ERR == CKrbConfigOptions::m_krbRealmEditbox.AddString(lineBuf))
+                       {
+                               MessageBox("OnInitDialog::Can't add to Kerberos Realm Combobox",
+                                                  "Leash", MB_OK);
+                               return;
+                       }
+               }
+       }
+
+       CHAR krbhst[MAX_HSTNM + 1];
+       CHAR krbrlm[REALM_SZ + 1];
+
+       strcpy(krbrlm, CKrbConfigOptions::m_newDefaultRealm);
+       memset(krbhst, '\0', sizeof(krbhst));
+
+       // Check for Host
+       // don't use KRB4 - krb_get_krbhst - would have to re-logon, on file location
+       // change, to use this function
+       extern int krb_get_krbhst(char* h, char* r, int n);
+       if (KFAILURE == krb_get_krbhst(krbhst, krbrlm, 1))
+       {
+               MessageBox("We can't find the Host Server for your Default Realm!!!",
+                    "Leash", MB_OK);
+               return;
+       }
+
+       CKrbConfigOptions::m_hostServer = krbhst;
+}
+
+void CKrb4RealmHostMaintenance::OnButtonRealmHostAdd()
+{
+       CKrb4AddToRealmHostList addToRealmHostList;
+
+       if (IDOK == addToRealmHostList.DoModal())
+       {
+               if (addToRealmHostList.GetNewRealm().IsEmpty())
+                 ASSERT(0);
+
+               CString newLine;
+               newLine = addToRealmHostList.GetNewRealm() + " " + addToRealmHostList.GetNewHost();
+
+               if (addToRealmHostList.GetNewAdmin())
+                 newLine += " admin server";
+
+               // We don't want duplicate items in Listbox
+               if (LB_ERR != m_RealmHostList.FindStringExact(-1, newLine))
+               { // found duplicate item in Listbox
+                       LeashErrorBox("OnButtonRealmHostAdd::Found a Duplicate Item!\nCan't add to List",
+                                                 newLine);
+                       return;
+               }
+
+
+               m_RealmHostList.InsertString(0, newLine);
+               m_RealmHostList.SetCurSel(0);
+               SetModified(TRUE);
+
+               ResetDefaultRealmComboBox();
+
+               if (1 == m_RealmHostList.GetCount())
+               {
+                       GetDlgItem(ID_BUTTON_KRB4_REALM_HOST_REMOVE)->EnableWindow();
+                       GetDlgItem(IDC_BUTTON_KRB4_REALM_HOST_EDIT)->EnableWindow();
+               }
+       }
+}
+
+void CKrb4RealmHostMaintenance::OnButtonRealmHostEdit()
+{
+       INT selItemIndex = m_RealmHostList.GetCurSel();
+       LPSTR pSelItem = new char[m_RealmHostList.GetTextLen(selItemIndex) + 1];
+       if (!pSelItem)
+         ASSERT(0);
+
+       CString selItem;
+       m_RealmHostList.GetText(selItemIndex, selItem);
+       strcpy(pSelItem, selItem);
+
+       CKrb4EditRealmHostList editRealmHostList(pSelItem);
+       delete [] pSelItem;
+
+       if (IDOK == editRealmHostList.DoModal())
+       {
+               CString editedItem = editRealmHostList.GetEditedItem();
+               if (0 != selItem.CompareNoCase(editedItem) &&
+                       LB_ERR != m_RealmHostList.FindStringExact(-1, editedItem))
+               {
+                       LeashErrorBox("OnButtonRealmHostEdit::Found a Duplicate!\nCan't add to List",
+                                                         editedItem);
+
+                       return;
+               }
+
+               m_RealmHostList.DeleteString(selItemIndex);
+               m_RealmHostList.InsertString(selItemIndex, editRealmHostList.GetEditedItem());
+               m_RealmHostList.SetCurSel(selItemIndex);
+               SetModified(TRUE);
+
+               ResetDefaultRealmComboBox();
+       }
+}
+
+void CKrb4RealmHostMaintenance::OnButtonRealmHostRemove()
+{
+       if (IDYES != AfxMessageBox("You are about to remove an item from the list!\n\nContinue?",
+                                      MB_YESNO))
+         return;
+
+       INT curSel = m_RealmHostList.GetCurSel();
+       m_RealmHostList.DeleteString(curSel);  // Single Sel Listbox
+
+       if (-1 == m_RealmHostList.SetCurSel(curSel))
+         m_RealmHostList.SetCurSel(curSel - 1);
+
+       SetModified(TRUE);
+
+       ResetDefaultRealmComboBox();
+
+       if (!m_RealmHostList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_KRB4_REALM_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_KRB4_REALM_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       /* For Mult. Sel Listbox
+       const LONG MAX_SEL_BUF = m_RealmHostList.GetSelCount();
+       LPINT selectBuf = new INT[MAX_SEL_BUF];
+
+       for (INT maxSelected = m_RealmHostList.GetSelItems(MAX_SEL_BUF, selectBuf), del=0, sel=0;
+            sel < maxSelected; sel++)
+       {
+               if (LB_ERR == m_RealmHostList.DeleteString(*(selectBuf + sel) - del))
+                 MessageBox("Help", "Error", MB_OK);
+               else
+                 del++;
+       }
+
+       delete selectBuf;
+       */
+}
+
+void CKrb4RealmHostMaintenance::OnSelchangeListRemoveHost()
+{
+       //SetModified(TRUE);
+}
+
+
+void CKrb4RealmHostMaintenance::OnDblclkListRemoveHost()
+{
+       OnButtonRealmHostEdit();
+}
+
+BOOL CKrb4RealmHostMaintenance::PreTranslateMessage(MSG* pMsg)
+{
+       if (m_defectiveLines)
+       {
+               if (m_defectiveLines == 1)
+                 LeashErrorBox("Found a defective entry in file",
+                                               CKrbProperties::m_krbPath, "Warning");
+           else if (m_defectiveLines > 1)
+             LeashErrorBox("Found more then one defective entry in file",
+                                               CKrbProperties::m_krbPath, "Warning");
+       }
+
+       m_defectiveLines = 0;
+       return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+void CKrb4RealmHostMaintenance::OnButtonRealmhostMaintHelp2()
+{
+       MessageBox("No Help Available!", "Note", MB_OK);
+}
diff --git a/src/windows/leash/Krb4RealmHostMaintenance.h b/src/windows/leash/Krb4RealmHostMaintenance.h
new file mode 100644 (file)
index 0000000..26881c6
--- /dev/null
@@ -0,0 +1,86 @@
+//     **************************************************************************************
+//     File:                   Krb4RealmHostMaintenance.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4RealmHostMaintenance.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_REAMLHOSTMAINT_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_)
+#define AFX_REAMLHOSTMAINT_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// RemoveHostNameList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb4RealmHostMaintenance dialog
+
+#define MAXLINE 256
+
+class CKrb4RealmHostMaintenance : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrb4RealmHostMaintenance)
+       CHAR lineBuf[MAXLINE];
+       INT  m_defectiveLines;
+    BOOL m_initDnsKdcLookup;
+    BOOL m_newDnsKdcLookup;
+
+       void ResetDefaultRealmComboBox();
+
+public:
+       //CKrb4RealmHostMaintenance(CWnd* pParent = NULL);   // standard constructor
+       CKrb4RealmHostMaintenance();
+       virtual ~CKrb4RealmHostMaintenance();
+
+// Dialog Data
+       //{{AFX_DATA(CKrb4RealmHostMaintenance)
+       enum { IDD = IDD_KRB4_REALMHOST_MAINT2 };
+       CDragListBox    m_RealmHostList;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb4RealmHostMaintenance)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb4RealmHostMaintenance)
+       virtual BOOL OnInitDialog();
+       virtual BOOL OnApply();
+       virtual void OnOK();
+       virtual void OnCancel();
+       afx_msg void OnButtonRealmHostAdd();
+       afx_msg void OnButtonRealmHostEdit();
+       afx_msg void OnButtonRealmHostRemove();
+       afx_msg void OnSelchangeListRemoveHost();
+       afx_msg void OnDblclkListRemoveHost();
+       afx_msg void OnButtonRealmhostMaintHelp2();
+    afx_msg void OnCheckDnsKdcLookup();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_REAMLHOSTMAINT_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Krb5Properties.cpp b/src/windows/leash/Krb5Properties.cpp
new file mode 100644 (file)
index 0000000..c4ffef2
--- /dev/null
@@ -0,0 +1,644 @@
+//****************************************************************************
+// File:       Krb5Properties.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  1998 Massachusetts Institute of Technology - All rights
+//             reserved.
+// Description:        CPP file for Krb5Properties.h. Contains variables and functions
+//             for Kerberos Five Properties
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 12/02/98    ADL     Original
+//*****************************************************************************
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashFileDialog.h"
+#include "Krb5Properties.h"
+#include "win-mac.h"
+#include "lglobals.h"
+#include "LeashView.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb5ConfigFileLocation dialog
+
+IMPLEMENT_DYNCREATE(CKrb5ConfigFileLocation, CPropertyPage)
+
+CKrb5ConfigFileLocation::CKrb5ConfigFileLocation()
+    : CPropertyPage(CKrb5ConfigFileLocation::IDD)
+{
+    m_initConfigFile = _T("");
+    m_initTicketFile = _T("");
+    m_newConfigFile = _T("");
+    m_newTicketFile = _T("");
+    m_startupPage1 = TRUE;
+
+    //{{AFX_DATA_INIT(CKrb5ConfigFileLocation)
+    //}}AFX_DATA_INIT
+}
+
+void CKrb5ConfigFileLocation::DoDataExchange(CDataExchange* pDX)
+{
+    CDialog::DoDataExchange(pDX);
+    //{{AFX_DATA_MAP(CKrb5ConfigFileLocation)
+    DDX_Control(pDX, IDC_EDIT_KRB5_TXT_FILE, m_ticketEditBox);
+    //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CKrb5ConfigFileLocation, CDialog)
+    //{{AFX_MSG_MAP(CKrb5ConfigFileLocation)
+    ON_BN_CLICKED(IDC_BUTTON_KRB5INI_BROWSE, OnButtonKrb5iniBrowse)
+    ON_BN_CLICKED(IDC_BUTTON_KRB5_TICKETFILE_BROWSE, OnButtonKrb5TicketfileBrowse)
+    ON_EN_CHANGE(IDC_EDIT_KRB5_TXT_FILE, OnChangeEditKrb5TxtFile)
+    ON_EN_CHANGE(IDC_EDIT_KRB5INI_LOCATION, OnChangeEditKrb5iniLocation)
+    ON_WM_SHOWWINDOW()
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+BOOL CKrb5ConfigFileLocation::OnApply()
+{
+    BOOL tooManySlashes = FALSE;
+    BOOL foundError = FALSE;
+
+    if( getenv("RENEW_TILL") !=  NULL)
+    {
+        MessageBox("The ticket renewable time is being controlled by the environment"
+                   "variable RENEW_TILL instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if( getenv("RENEWABLE") !=  NULL)
+    {
+        MessageBox("Ticket renewability is being controlled by the environment"
+                   "variable RENEWABLE instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if( getenv("FORWARDABLE") !=  NULL)
+    {
+        MessageBox("Ticket forwarding is being controlled by the environment"
+                   "variable FORWARDABLE instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if( getenv("PROXIABLE") !=  NULL)
+    {
+        MessageBox("Ticket proxying is being controlled by the environment"
+                   "variable PROXIABLE instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if( getenv("NOADDRESSES") !=  NULL)
+    {
+        MessageBox("Addressless tickets are being controlled by the environment"
+                   "variable NOADDRESSES instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+
+    // KRB5.INI file
+    if (!CLeashApp::m_krbv5_profile ||
+       0 != m_newConfigFile.CompareNoCase(m_initConfigFile))
+    { // Different path for Krb5.ini
+
+        if (IsDlgButtonChecked(IDC_CHECK_CONFIRM_KRB5_EXISTS))
+        {
+            // Check for extra slashes at end of path
+            LPSTR pSlash = strrchr(m_newConfigFile.GetBuffer(0), '\\');
+            if (pSlash && *(pSlash - 1) == '\\')
+            { // don't commit changes
+                tooManySlashes = TRUE;
+            }
+            else if (pSlash && *(pSlash + 1) == '\0')
+            { // commit changes, but take out slash at the end of path
+                *pSlash = 0;
+            }
+
+            m_newConfigFile.ReleaseBuffer(-1);
+
+            // Check for invalid path
+            Directory directory(m_newConfigFile);
+            if (tooManySlashes || !directory.IsValidFile())
+            { // don't commit changes
+                foundError = TRUE;
+
+                if (tooManySlashes)
+                    LeashErrorBox("OnApply::Too Many Slashes At End of "
+                                  "Selected Directory",
+                                  m_newConfigFile);
+                else
+                    LeashErrorBox("OnApply::Selected file doesn't exist",
+                                  m_newConfigFile);
+
+                SetDlgItemText(IDC_EDIT_KRB5INI_LOCATION, m_initConfigFile);
+            }
+            else
+            {
+                // more error checking
+                CHAR confname[MAX_PATH];
+
+                const char *filenames[2];
+                filenames[0] = m_newConfigFile;
+                filenames[1] = NULL;
+
+                const char*  rootSection[] = {"realms", NULL};
+                const char** rootsec = rootSection;
+                char **sections = NULL;
+
+                long retval = pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+                if (!retval)
+                    retval = pprofile_get_subsection_names(CLeashApp::m_krbv5_profile,
+                                                           rootsec, &sections
+                                                           );
+                if (retval || !*sections )
+                {
+                    foundError = TRUE;
+                    MessageBox("Your file selection is either corrupt or not a Kerberos Five Config. file",
+                               "Leash", MB_OK);
+
+                    pprofile_free_list(sections);
+
+                    // Restore old 'valid' config. file
+                    if (CLeashApp::GetProfileFile(confname, sizeof(confname)))
+                    {
+                        foundError = TRUE;
+                        MessageBox("Can't locate Kerberos Five Config. file!",
+                                   "Error", MB_OK);
+                        return TRUE;
+                    }
+
+                    filenames[0] = confname;
+                    filenames[1] = NULL;
+
+                    retval = pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+                    if (!retval)
+                        retval = pprofile_get_subsection_names(CLeashApp::m_krbv5_profile,
+                                                               rootsec, &sections);
+                    if (retval || !*sections)
+                    {
+                        foundError = TRUE;
+                        MessageBox("OnApply::There is a problem with your "
+                                   "Kerberos Five Config. file!\n"
+                                   "Contact your Administrator.",
+                                   "Leash", MB_OK);
+                    }
+
+                    pprofile_free_list(sections);
+                    SetDlgItemText(IDC_EDIT_KRB5INI_LOCATION, m_initConfigFile);
+
+                    pprofile_release(CLeashApp::m_krbv5_profile);
+                    return TRUE;
+                }
+
+                pprofile_free_list(sections);
+           }
+        }
+
+        // Commit changes
+        if (!foundError)
+        {
+            if (SetRegistryVariable("config", m_newConfigFile,
+                                    "Software\\MIT\\Kerberos5"))
+            {
+                MessageBox("Failed to set \"Krb.conf\"!", "Error", MB_OK);
+            }
+
+            m_initConfigFile = m_newConfigFile;
+            SetModified(TRUE);
+        }
+    }
+
+    // Credential cache (ticket) file
+    // Ticket file
+    if (0 != m_initTicketFile.CompareNoCase(m_newTicketFile))
+    {
+        if (getenv("KRB5_ENV_CCNAME"))
+        {
+            // Just in case they set (somehow) KRB5_ENV_CCNAME while this box is up
+            MessageBox("OnApply::Ticket file is set in your System's"
+                       "Environment!\nYou must first remove it.",
+                       "Error", MB_OK);
+
+            return TRUE;
+        }
+
+        // Commit changes
+        if (SetRegistryVariable("ccname", m_newTicketFile,
+                                "Software\\MIT\\Kerberos5"))
+        {
+            MessageBox("Failed to set \"ccname\"!", "Error", MB_OK);
+        }
+        if ( CLeashApp::m_krbv5_context )
+            pkrb5_cc_set_default_name(CLeashApp::m_krbv5_context,m_newTicketFile);
+
+        m_initTicketFile = m_newTicketFile;
+    }
+
+    return TRUE;
+}
+
+
+BOOL CKrb5ConfigFileLocation::OnInitDialog()
+{
+    CDialog::OnInitDialog();
+
+    CHAR confname[MAX_PATH];
+    CHAR ticketName[MAX_PATH];
+
+    CheckDlgButton(IDC_CHECK_CONFIRM_KRB5_EXISTS, TRUE);
+
+    // Config. file (Krb5.ini)
+    if (CLeashApp::GetProfileFile(confname, sizeof(confname)))
+    {
+        MessageBox("Can't locate Kerberos Five config. file!", "Error", MB_OK);
+        return TRUE;
+    }
+
+    m_initConfigFile = m_newConfigFile = confname;
+    SetDlgItemText(IDC_EDIT_KRB5INI_LOCATION, m_initConfigFile);
+
+    if (pLeash_get_lock_file_locations() || getenv("KRB5_CONFIG"))
+    {
+        GetDlgItem(IDC_EDIT_KRB5INI_LOCATION)->EnableWindow(FALSE);
+        GetDlgItem(IDC_BUTTON_KRB5INI_BROWSE)->EnableWindow(FALSE);
+        GetDlgItem(IDC_CHECK_CONFIRM_KRB5_EXISTS)->EnableWindow(FALSE);
+    }
+    else if ( !(getenv("KRB5_CONFIG")) )
+    {
+        GetDlgItem(IDC_STATIC_INIFILES)->ShowWindow(FALSE);
+    }
+
+
+    // Set TICKET.KRB file Editbox
+    *ticketName = NULL;
+    if (CLeashApp::m_krbv5_context)
+    {
+        const char *pticketName = pkrb5_cc_default_name(CLeashApp::m_krbv5_context);
+
+        if (pticketName)
+            strcpy(ticketName, pticketName);
+    }
+
+    if (!*ticketName)
+    {
+        MessageBox("OnInitDialog::Can't locate Kerberos Five ticket file!",
+                   "Error", MB_OK);
+        return TRUE;
+    }
+    else
+    {
+        m_initTicketFile = m_newTicketFile = ticketName;
+        SetDlgItemText(IDC_EDIT_KRB5_TXT_FILE, m_initTicketFile);
+    }
+
+    if (getenv("KRB5CCNAME"))
+        GetDlgItem(IDC_EDIT_KRB5_TXT_FILE)->EnableWindow(FALSE);
+    else
+        GetDlgItem(IDC_STATIC_TICKETFILE)->ShowWindow(FALSE);
+
+    return TRUE;
+}
+
+void CKrb5ConfigFileLocation::OnButtonKrb5iniBrowse()
+{
+    CLeashFileDialog dlgFile(TRUE, NULL, "*.*",
+                             "Kerbereos Five Config. File (.ini)");
+    dlgFile.m_ofn.lpstrTitle = "Select the Kerberos Five Config. File";
+    while (TRUE)
+    {
+        if (IDOK == dlgFile.DoModal())
+        {
+            m_newConfigFile = dlgFile.GetPathName();
+            SetDlgItemText(IDC_EDIT_KRB5INI_LOCATION, m_newConfigFile);
+            break;
+        }
+        else
+            break;
+    }
+}
+
+void CKrb5ConfigFileLocation::OnButtonKrb5TicketfileBrowse()
+{
+    CString ticket_path = "*.*";
+    CLeashFileDialog dlgFile(TRUE, NULL, ticket_path,
+                             "Kerbereos Five Ticket File (Krb5cc)");
+    dlgFile.m_ofn.lpstrTitle = "Select Credential Cache (Ticket) File";
+
+    if (IDOK == dlgFile.DoModal())
+    {
+        m_newTicketFile = dlgFile.GetPathName();
+        SetDlgItemText(IDC_EDIT_KRB5_TXT_FILE, m_newTicketFile);
+    }
+}
+
+void CKrb5ConfigFileLocation::OnChangeEditKrb5iniLocation()
+{
+    if (!m_startupPage1)
+    {
+        GetDlgItemText(IDC_EDIT_KRB5INI_LOCATION, m_newConfigFile);
+        SetModified(TRUE);
+    }
+}
+
+void CKrb5ConfigFileLocation::OnChangeEditKrb5TxtFile()
+{
+    if (!m_startupPage1)
+    {
+        GetDlgItemText(IDC_EDIT_KRB5_TXT_FILE, m_newTicketFile);
+        SetModified(TRUE);
+    }
+}
+
+void CKrb5ConfigFileLocation::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+    CDialog::OnShowWindow(bShow, nStatus);
+    m_startupPage1 = FALSE;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb5ConfigOptions dialog
+
+IMPLEMENT_DYNCREATE(CKrb5ConfigOptions, CPropertyPage)
+
+CKrb5ConfigOptions::CKrb5ConfigOptions()
+       : CPropertyPage(CKrb5ConfigOptions::IDD)
+{
+    m_initForwardable = 0;
+    m_newForwardable = 0;
+    m_initProxiable = 0;
+    m_newProxiable = 0;
+    m_initRenewable = 0;
+    m_newRenewable = 0;
+    m_initNoAddress = 0;
+    m_newNoAddress = 0;
+    m_initIPAddress = 0;
+#ifdef SET_PUBLIC_IP
+    m_newIPAddress = 0;
+#endif /* SET_PUBLIC_IP */
+
+    //{{AFX_DATA_INIT(CKrb5ConfigOptions)
+    // NOTE: the ClassWizard will add member initialization here
+    //}}AFX_DATA_INIT
+}
+
+
+void CKrb5ConfigOptions::DoDataExchange(CDataExchange* pDX)
+{
+    CDialog::DoDataExchange(pDX);
+
+    //{{AFX_DATA_MAP(CKrb5ConfigOptions)
+    // NOTE: the ClassWizard will add DDX and DDV calls here
+    //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrb5ConfigOptions, CDialog)
+    //{{AFX_MSG_MAP(CKrb5ConfigOptions)
+    ON_BN_CLICKED(IDC_CHECK_FORWARDABLE, OnCheckForwardable)
+    ON_BN_CLICKED(IDC_CHECK_PROXIABLE, OnCheckProxiable)
+    ON_BN_CLICKED(IDC_CHECK_RENEWABLE, OnCheckRenewable)
+    ON_BN_CLICKED(IDC_CHECK_NO_ADDRESS, OnCheckNoAddress)
+    ON_WM_HELPINFO()
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+BOOL CKrb5ConfigOptions::OnApply()
+{
+#ifdef SET_PUBLIC_IP
+    SendDlgItemMessage( IDC_IPADDRESS_PUBLIC,
+                        IPM_GETADDRESS,
+                        0,
+                        (LPARAM)(LPDWORD)&m_newIPAddress
+                      );
+#endif /* SET_PUBLIC_IP */
+
+    if ((m_initForwardable == m_newForwardable) &&
+        (m_initProxiable == m_newProxiable) &&
+        (m_initRenewable == m_newRenewable) &&
+        (m_initNoAddress == m_newNoAddress)
+#ifdef SET_PUBLIC_IP
+         && (m_initIPAddress == m_newIPAddress)
+#endif /* SET_PUBLIC_IP */
+         )
+        return TRUE;
+
+    CWinApp *pApp = NULL;
+    pApp = AfxGetApp();
+    if (!pApp)
+    {
+        MessageBox("There is a problem finding Leash application "
+                   "information!",
+                   "Error", MB_OK);
+        return FALSE;
+    }
+
+    if ( m_newNoAddress == FALSE ) {
+        CHAR confname[MAX_PATH];
+        if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+        {
+            const char *filenames[2];
+            char *value=NULL;
+            long retval, noaddresses = 1;
+            filenames[0] = confname;
+            filenames[1] = NULL;
+            retval = pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+            if (!retval) {
+                retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults","noaddresses", 0, "true", &value);
+                if ( value ) {
+                    noaddresses = config_boolean_to_int(value);
+                    pprofile_release_string(value);
+                }
+                pprofile_release(CLeashApp::m_krbv5_profile);
+            }
+
+            if ( noaddresses )
+            {
+                MessageBox("The No Addresses setting cannot be disabled unless the setting\n"
+                           "    noaddresses=false\n"
+                           "is added to the [libdefaults] section of the KRB5.INI file.",
+                            "Error", MB_OK);
+                return FALSE;
+
+            }
+        }
+    }
+
+    pLeash_set_default_forwardable(m_newForwardable);
+    pLeash_set_default_proxiable(m_newProxiable);
+    pLeash_set_default_renewable(m_newRenewable);
+    pLeash_set_default_noaddresses(m_newNoAddress);
+#ifdef SET_PUBLIC_IP
+    pLeash_set_default_publicip(m_newIPAddress);
+#endif /* SET_PUBLIC_IP */
+
+    CLeashView::m_forwardableTicket = m_initForwardable = m_newForwardable;
+    CLeashView::m_proxiableTicket = m_initProxiable = m_newProxiable;
+    CLeashView::m_renewableTicket = m_initRenewable = m_newRenewable;
+    CLeashView::m_noaddressTicket = m_initNoAddress = m_newNoAddress;
+#ifdef SET_PUBLIC_IP
+    CLeashView::m_publicIPAddress = m_initIPAddress = m_newIPAddress;
+#endif /* SET_PUBLIC_IP */
+    return TRUE;
+}
+
+BOOL CKrb5ConfigOptions::OnInitDialog()
+{
+    CDialog::OnInitDialog();
+
+    CWinApp *pApp = NULL;
+    pApp = AfxGetApp();
+    if (!pApp)
+    {
+        MessageBox("There is a problem finding Leash application "
+                   "information!",
+                   "Error", MB_OK);
+    }
+    else
+    {
+        m_initForwardable = pLeash_get_default_forwardable();
+        m_initProxiable = pLeash_get_default_proxiable();
+        m_initRenewable = pLeash_get_default_renewable();
+        m_initNoAddress = pLeash_get_default_noaddresses();
+        m_initIPAddress = pLeash_get_default_publicip();
+    }
+
+    CheckDlgButton(IDC_CHECK_FORWARDABLE, m_initForwardable);
+    m_newForwardable = m_initForwardable;
+
+    CheckDlgButton(IDC_CHECK_PROXIABLE, m_initProxiable);
+    m_newProxiable = m_initProxiable;
+
+    CheckDlgButton(IDC_CHECK_RENEWABLE, m_initRenewable);
+    m_newRenewable = m_initRenewable;
+
+    CheckDlgButton(IDC_CHECK_NO_ADDRESS, m_initNoAddress);
+    m_newNoAddress = m_initNoAddress;
+
+    if ( m_initNoAddress ) {
+        // Disable the control - jaltman
+
+        SendDlgItemMessage( IDC_IPADDRESS_PUBLIC,
+                            IPM_CLEARADDRESS,
+                            0,
+                            0
+                            );
+    }
+    else {
+        SendDlgItemMessage( IDC_IPADDRESS_PUBLIC,
+                            IPM_SETADDRESS,
+                            0,
+                            (LPARAM)m_initIPAddress
+                            );
+    }
+#ifdef SET_PUBLIC_IP
+    m_newIPAddress = m_initIPAddress;
+#endif /* SET_PUBLIC_IP */
+
+    return TRUE;  // return TRUE unless you set the focus to a control
+                  // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CKrb5ConfigOptions::OnCheckForwardable()
+{
+    m_newForwardable = (BOOL)IsDlgButtonChecked(IDC_CHECK_FORWARDABLE);
+    SetModified(TRUE);
+}
+
+void CKrb5ConfigOptions::OnCheckProxiable()
+{
+    m_newProxiable = (BOOL)IsDlgButtonChecked(IDC_CHECK_PROXIABLE);
+    SetModified(TRUE);
+}
+
+void CKrb5ConfigOptions::OnCheckRenewable()
+{
+    m_newRenewable = (BOOL)IsDlgButtonChecked(IDC_CHECK_RENEWABLE);
+    SetModified(TRUE);
+}
+
+void CKrb5ConfigOptions::OnCheckNoAddress()
+{
+    m_newNoAddress = (BOOL)IsDlgButtonChecked(IDC_CHECK_NO_ADDRESS);
+    SetModified(TRUE);
+
+    if ( m_newNoAddress ) {
+        // Disable the control - jaltman
+
+        SendDlgItemMessage( IDC_IPADDRESS_PUBLIC,
+                            IPM_CLEARADDRESS,
+                            0,
+                            0
+                            );
+    } else {
+        // Enable the IP Address Control - jaltman
+
+        SendDlgItemMessage( IDC_IPADDRESS_PUBLIC,
+                            IPM_SETADDRESS,
+                            0,
+                            (LPARAM)m_initIPAddress
+                            );
+    }
+}
+
+///////////////////////////////////////////////////////////////////////
+// CKrb5Properties
+
+IMPLEMENT_DYNAMIC(CKrb5Properties, CPropertySheet)
+
+CKrb5Properties::CKrb5Properties(UINT nIDCaption, CWnd* pParentWnd,
+                                 UINT iSelectPage)
+    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+{
+}
+
+CKrb5Properties::CKrb5Properties(LPCTSTR pszCaption, CWnd* pParentWnd,
+                                 UINT iSelectPage)
+    :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+{
+    AddPage(&m_fileLocation);
+    AddPage(&m_configOptions);
+}
+
+CKrb5Properties::~CKrb5Properties()
+{
+}
+
+void CKrb5Properties::OnHelp()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_KRB5_PROPERTIES_COMMAND);
+#else
+    AfxGetApp()->WinHelp(HID_KRB5_PROPERTIES_COMMAND);
+#endif
+}
+
+
+
+BEGIN_MESSAGE_MAP(CKrb5Properties, CPropertySheet)
+    //{{AFX_MSG_MAP(CKrb5Properties)
+    // NOTE - the ClassWizard will add and remove mapping macros here.
+    ON_COMMAND(ID_HELP, OnHelp)
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
diff --git a/src/windows/leash/Krb5Properties.h b/src/windows/leash/Krb5Properties.h
new file mode 100644 (file)
index 0000000..c091ddd
--- /dev/null
@@ -0,0 +1,172 @@
+//     **************************************************************************************
+//     File:                   Krb5Properties.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb5Properties.cpp. Contains variables and functions
+//                                     for Kerberos Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_KRB5PROPERTIES_H__9011A0B3_6E92_11D2_9454_0000861B8A3C__INCLUDED_)
+#define AFX_KRB5PROPERTIES_H__9011A0B3_6E92_11D2_9454_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// Krb5Properties.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb5ConfigOptions dialog
+
+class CKrb5ConfigFileLocation : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrb5ConfigFileLocation)
+       CString m_initConfigFile;
+       CString m_initTicketFile;
+       CString m_newConfigFile;
+       CString m_newTicketFile;
+       BOOL m_startupPage1;
+
+public:
+       CKrb5ConfigFileLocation();   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CKrb5ConfigFileLocation)
+       enum { IDD = IDD_KRB5_PROP_LOCATION };
+       CEdit   m_ticketEditBox;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb5ConfigFileLocation)
+       public:
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       virtual BOOL OnApply();
+
+ // Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb5ConfigFileLocation)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnButtonKrb5iniBrowse();
+       afx_msg void OnButtonKrb5TicketfileBrowse();
+       afx_msg void OnChangeEditKrb5TxtFile();
+       afx_msg void OnChangeEditKrb5iniLocation();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrb5ConfigOptions dialog
+
+class CKrb5ConfigOptions : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrb5ConfigOptions)
+       INT m_initForwardable;
+       INT m_newForwardable;
+       INT m_initProxiable;
+       INT m_newProxiable;
+       INT m_initRenewable;
+       INT m_newRenewable;
+       INT m_initNoAddress;
+       INT m_newNoAddress;
+    DWORD m_initIPAddress;
+#ifdef SET_PUBLIC_IP
+    DWORD m_newIPAddress;
+#endif /* SET_PUBLIC_IP */
+
+public:
+       CKrb5ConfigOptions();   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CKrb5ConfigOptions)
+       enum { IDD = IDD_KRB5_PROP_CONTENT };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb5ConfigOptions)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       virtual BOOL OnApply();
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrb5ConfigOptions)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnCheckForwardable();
+       afx_msg void OnCheckProxiable();
+       afx_msg void OnCheckRenewable();
+       afx_msg void OnCheckNoAddress();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+class CKrb5Properties : public CPropertySheet
+{
+private:
+       DECLARE_DYNAMIC(CKrb5Properties)
+
+public:
+       CKrb5ConfigFileLocation m_fileLocation;
+       CKrb5ConfigOptions m_configOptions;
+
+// Construction
+public:
+       CKrb5Properties(UINT nIDCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+       CKrb5Properties(LPCTSTR pszCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrb5Properties)
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CKrb5Properties();
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CKrb5Properties)
+               // NOTE - the ClassWizard will add and remove member functions here.
+    afx_msg void OnHelp();
+    //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRB5PROPERTIES_H__9011A0B3_6E92_11D2_9454_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbAddHostServer.cpp b/src/windows/leash/KrbAddHostServer.cpp
new file mode 100644 (file)
index 0000000..fc53e41
--- /dev/null
@@ -0,0 +1,77 @@
+// KrbAddHostServer.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbAddHostServer.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddHostServer dialog
+
+
+CKrbAddHostServer::CKrbAddHostServer(CWnd* pParent /*=NULL*/)
+       : CDialog(CKrbAddHostServer::IDD, pParent)
+{
+       m_newHost = _T("");
+       m_startup = TRUE;
+
+       //{{AFX_DATA_INIT(CKrbAddHostServer)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CKrbAddHostServer::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbAddHostServer)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbAddHostServer, CDialog)
+       //{{AFX_MSG_MAP(CKrbAddHostServer)
+       ON_EN_CHANGE(IDC_EDIT_KDC_HOST, OnChangeEditKdcHost)
+       ON_WM_SHOWWINDOW()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddHostServer message handlers
+
+void CKrbAddHostServer::OnOK()
+{
+       m_newHost.TrimLeft();
+       m_newHost.TrimRight();
+
+       if (m_newHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK:: Server Hosting a KDC must be filled in!",
+                    "Error", MB_OK);
+       }
+       else if (-1 != m_newHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Error", MB_OK);
+       }
+       else
+         CDialog::OnOK(); // exit
+}
+
+void CKrbAddHostServer::OnChangeEditKdcHost()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_KDC_HOST, m_newHost);
+}
+
+void CKrbAddHostServer::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
diff --git a/src/windows/leash/KrbAddHostServer.h b/src/windows/leash/KrbAddHostServer.h
new file mode 100644 (file)
index 0000000..989d388
--- /dev/null
@@ -0,0 +1,53 @@
+#if !defined(AFX_KRBADDHOSTSERVER_H__1B6B6ED8_D26D_11D2_95AF_0000861B8A3C__INCLUDED_)
+#define AFX_KRBADDHOSTSERVER_H__1B6B6ED8_D26D_11D2_95AF_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// KrbAddHostServer.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddHostServer dialog
+
+class CKrbAddHostServer : public CDialog
+{
+// Construction
+       CString m_newHost;
+       BOOL m_startup;
+
+public:
+       CKrbAddHostServer(CWnd* pParent = NULL);   // standard constructor
+       CString GetNewHost() {return m_newHost;}
+
+
+// Dialog Data
+       //{{AFX_DATA(CKrbAddHostServer)
+       enum { IDD = IDD_KRB_ADD_KDC_HOSTSERVER};
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbAddHostServer)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbAddHostServer)
+       virtual void OnOK();
+       afx_msg void OnChangeEditKdcHost();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRBADDHOSTSERVER_H__1B6B6ED8_D26D_11D2_95AF_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbAddRealm.cpp b/src/windows/leash/KrbAddRealm.cpp
new file mode 100644 (file)
index 0000000..4527e4b
--- /dev/null
@@ -0,0 +1,88 @@
+//     File:                   KrbAddRealm.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbAddRealm.h. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbAddRealm.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddRealm dialog
+
+
+CKrbAddRealm::CKrbAddRealm(CWnd* pParent /*=NULL*/)
+: CDialog(CKrbAddRealm::IDD, pParent)
+{
+       m_newRealm = _T("");
+       m_startup = TRUE;
+
+       //{{AFX_DATA_INIT(CKrbAddRealm)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CKrbAddRealm::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbAddRealm)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbAddRealm, CDialog)
+       //{{AFX_MSG_MAP(CKrbAddRealm)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_REALM, OnChangeEditRealm)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddRealm message handlers
+
+void CKrbAddRealm::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+void CKrbAddRealm::OnChangeEditRealm()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_REALM, m_newRealm);
+}
+
+void CKrbAddRealm::OnOK()
+{
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+
+       if (m_newRealm.IsEmpty())
+       { // stay
+               MessageBox("OnOK:: Kerberos Realm must be filled in!",
+                   "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+       else
+         CDialog::OnOK(); // exit
+}
diff --git a/src/windows/leash/KrbAddRealm.h b/src/windows/leash/KrbAddRealm.h
new file mode 100644 (file)
index 0000000..48ae4b7
--- /dev/null
@@ -0,0 +1,66 @@
+//     **************************************************************************************
+//     File:                   KrbAddRealm.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbAddRealm.cpp Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
+#define AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AddToRealmHostList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbAddRealm dialog
+
+class CKrbAddRealm : public CDialog
+{
+// Construction
+       CString m_newRealm;
+       BOOL m_startup;
+
+public:
+       CKrbAddRealm(CWnd* pParent = NULL);   // standard constructor
+       CString GetNewRealm() {return m_newRealm;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrbAddRealm)
+       enum { IDD = IDD_KRB_ADD_REALM };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbAddRealm)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbAddRealm)
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       virtual void OnOK();
+       afx_msg void OnChangeEditRealm();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_ADDTOREALMHOSTLIST_H__26A1E1F3_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbConfigOptions.cpp b/src/windows/leash/KrbConfigOptions.cpp
new file mode 100644 (file)
index 0000000..2e1599c
--- /dev/null
@@ -0,0 +1,679 @@
+//     **************************************************************************************
+//     File:                   KrbConfigOptions.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbProperties.h. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     2/01/98 ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "Leash.h"
+#include "KrbProperties.h"
+#include "KrbConfigOptions.h"
+#include "LeashFileDialog.h"
+#include "LeashMessageBox.h"
+#include "wshelper.h"
+#include "lglobals.h"
+#include <io.h>
+#include <direct.h>
+#include "reminder.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+///////////////////////////////////////////////////////////////////////
+// CKrbConfigOptions property page
+
+CString CKrbConfigOptions::m_newDefaultRealm;
+CString CKrbConfigOptions::m_hostServer;
+CComboBox CKrbConfigOptions::m_krbRealmEditbox;
+BOOL CKrbConfigOptions::m_profileError;
+BOOL CKrbConfigOptions::m_dupEntriesError;
+
+IMPLEMENT_DYNCREATE(CKrbConfigOptions, CPropertyPage)
+
+CKrbConfigOptions::CKrbConfigOptions() : CPropertyPage(CKrbConfigOptions::IDD)
+{
+       m_initDefaultRealm = _T("");
+       m_newDefaultRealm = _T("");
+       m_startupPage2 = TRUE;
+       m_noKrbFileError = FALSE;
+       m_noKrbhostWarning = FALSE;
+       m_dupEntriesError = FALSE;
+       m_profileError  = FALSE;
+       m_noRealm = FALSE;
+
+       //{{AFX_DATA_INIT(CKrbConfigOptions)
+       //}}AFX_DATA_INIT
+}
+
+CKrbConfigOptions::~CKrbConfigOptions()
+{
+}
+
+VOID CKrbConfigOptions::DoDataExchange(CDataExchange* pDX)
+{
+       TRACE("Entering CKrbConfigOptions::DoDataExchange -- %d\n",
+             pDX->m_bSaveAndValidate);
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbConfigOptions)
+       DDX_Control(pDX, IDC_EDIT_DEFAULT_REALM, m_krbRealmEditbox);
+       //}}AFX_DATA_MAP
+}
+
+static char far * near parse_str(char far*buffer,char far*result)
+{
+        while (isspace(*buffer))
+                buffer++;
+        while (!isspace(*buffer))
+                *result++=*buffer++;
+        *result='\0';
+        return buffer;
+}
+
+int krb_get_krbhst(char* h, char* r, int n)
+{
+       char lbstorage[BUFSIZ];
+    char tr[REALM_SZ];
+    static FILE *cnffile; /*XXX pbh added static because of MS bug in fgets() */
+    static char FAR *linebuf; /*XXX pbh added static because of MS bug in fgets() */
+    int i;
+    char *p;
+
+    //static char buffer[80];
+    //krb_get_krbconf(buffer);
+    memset(lbstorage, '\0', BUFSIZ ); /* 4-22-94 */
+    linebuf = &lbstorage[0];
+
+    if ((cnffile = fopen(CKrbProperties::m_krbPath,"r")) == NULL) {
+        if (n==1) {
+            (void) strcpy(h,KRB_HOST);
+            return(KSUCCESS);
+        } else {
+            return(KFAILURE);
+        }
+    }
+    /* linebuf=(char FAR *)malloc(BUFSIZ); */ /*4-22-94*/
+    if (fgets(linebuf,BUFSIZ,cnffile)==NULL) {
+            /* free(linebuf); */ /* 4-22-94 */
+
+            return(KFAILURE);
+    }
+    /* bzero( tr, sizeof(tr) ); */   /* pbh 2-24-93 */
+    memset(tr, '\0', sizeof(tr) );
+    parse_str(linebuf,tr);
+    if (*tr=='\0') {
+            return (KFAILURE);
+    }
+    /* run through the file, looking for the nth server for this realm */
+    for (i = 1; i <= n;) {
+        if (fgets(linebuf, BUFSIZ, cnffile) == NULL) {
+            /* free(linebuf); */ /*4-22-94*/
+            (void) fclose(cnffile);
+            return(KFAILURE);
+        }
+        /* bzero( tr, sizeof(tr) ); */   /* pbh 2-24-93 */
+        memset(tr, '\0', sizeof(tr) );
+        p=parse_str(linebuf,tr);
+        if (*tr=='\0')
+                continue;
+        memset(h, '\0', lstrlen(h) );
+        parse_str(p,h);
+        if (*tr=='\0')
+                continue;
+        if (!lstrcmp(tr,r))
+                i++;
+    }
+    /* free(linebuf); */ /*4-22-94*/
+    (void) fclose(cnffile);
+    return(KSUCCESS);
+}
+
+BOOL CKrbConfigOptions::OnInitDialog()
+{
+    m_initDefaultRealm = _T("");
+    m_newDefaultRealm = _T("");
+    m_noKrbFileError = FALSE;
+    m_noKrbhostWarning = FALSE;
+    m_dupEntriesError = FALSE;
+    m_profileError     = FALSE;
+    m_noRealm = FALSE;
+
+    CPropertyPage::OnInitDialog();
+
+       if (CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL)
+       {  // Krb4 NOT krb5
+               // Fill in all edit boxes
+               char krbRealm[REALM_SZ + 1];
+               char krbhst[MAX_HSTNM + 1];
+               CStdioFile krbCon;
+               if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeRead))
+               {
+                       SetDlgItemText(IDC_EDIT_DEFAULT_REALM, KRB_REALM);
+                       SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, KRB_MASTER);
+                       //CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER);
+                       m_initDefaultRealm = m_newDefaultRealm = KRB_REALM;
+               }
+               else
+               { // place krbRealm in Edit box
+                       memset(krbRealm, '\0', sizeof(krbRealm));
+                       if (!krbCon.ReadString(krbRealm, sizeof(krbRealm)) || '\r' == *krbRealm  ||
+                               '\n' == *krbRealm || '\0' == *krbRealm)
+                       {
+                               SetDlgItemText(IDC_EDIT_DEFAULT_REALM, KRB_REALM);
+                               SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, KRB_MASTER);
+                               m_initDefaultRealm = m_newDefaultRealm = KRB_REALM;
+                       }
+                       else
+                       {
+                               *(krbRealm + strlen(krbRealm) - 1) = 0;
+                               LPSTR pSpace = strchr(krbRealm, ' ');
+                               if (pSpace)
+                                 *pSpace = 0;
+
+                               m_initDefaultRealm = m_newDefaultRealm = krbRealm;
+
+                               memset(krbhst, '\0', sizeof(krbhst));
+                               krbCon.Close();
+
+                               // Check for Host
+                               // don't use KRB4 - krb_get_krbhst - would have to re-logon, on file location
+                               // change, to use this function
+                               if (KFAILURE == pkrb_get_krbhst(krbhst, krbRealm, 1))
+                               {
+                                       m_noKrbhostWarning = TRUE;
+                               }
+                               else
+                               { // place hostname in Edit Box
+                                       //SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, krbhst);
+
+                                       m_hostServer = krbhst;
+
+                                       // New suff to put realms in Combo Box
+                                       CStdioFile krbCon;
+                                       if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeRead))
+                                       {
+                                               m_noKrbFileError = TRUE;
+                                               m_noRealm = TRUE;
+                                       } else {
+
+                                               LPSTR space = NULL;
+                                               CHAR lineBuf[REALM_SZ + MAX_HSTNM + 20];
+                                               CHAR localRealm[REALM_SZ + MAX_HSTNM + 20];
+                                               memset(lineBuf, '\0', sizeof(lineBuf));
+                                               memset(localRealm, '\0', sizeof(localRealm));
+
+                                               if (krbCon.ReadString(localRealm, sizeof(localRealm)))
+                                                 *(localRealm + strlen(localRealm) - 1) = 0;
+                                               else
+                                                 return FALSE;
+
+                                               space = strchr(localRealm, ' ');
+                                               if (space)
+                                                 *space = 0;
+
+                                               while (TRUE)
+                                               {
+                                                       if (!krbCon.ReadString(lineBuf, sizeof(lineBuf)))
+                                                         break;
+
+                                                       *(lineBuf + sizeof(lineBuf) - 1) = 0;
+
+                                                       if (strlen(lineBuf) == 0)
+                                                               continue;
+
+                                                       space = strchr(lineBuf, ' ');
+                                                       if (!space) space = strchr(lineBuf, '\t');
+                                                       if (space)
+                                                         *space = 0;
+                                                       else
+                                                         ASSERT(0);
+
+                            // skip Kerberos Options
+                            if ( !strncmp(".KERBEROS.OPTION.",lineBuf,17) )
+                                continue;
+
+                                                       if (CB_ERR == m_krbRealmEditbox.FindStringExact(-1, lineBuf))
+                                                       { // no dups
+                                                               if (LB_ERR == m_krbRealmEditbox.AddString(lineBuf))
+                                                               {
+                                                                       MessageBox("OnInitDialog::Can't add to Kerberos Realm Combobox",
+                                                                                  "Leash", MB_OK);
+                                                                       return FALSE;
+                                                               }
+                                                       }
+                                               }
+
+                                               m_krbRealmEditbox.SelectString(-1, krbRealm);
+
+                                       } // end of 'else'
+                               } // end of 'place hostname in Edit Box' else statement
+                       } // end of 'Check for Host' else statement
+               } // end of 'place krbRealm in Edit box' else
+       }
+       else if (CLeashApp::m_hKrb5DLL)
+       { // Krb5 OR krb5 AND krb4
+               char *realm = NULL;
+               pkrb5_get_default_realm(CLeashApp::m_krbv5_context, &realm);
+
+               if (!realm)
+                       m_noRealm = TRUE;
+
+               m_initDefaultRealm = m_newDefaultRealm = realm;
+
+           if ( !CLeashApp::m_krbv5_profile ) {
+            CHAR confname[MAX_PATH];
+            if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+            {
+                const char *filenames[2];
+                filenames[0] = confname;
+                filenames[1] = NULL;
+                pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+            }
+           }
+
+        CHAR selRealm[REALM_SZ];
+        strcpy(selRealm, m_newDefaultRealm);
+        const char*  Section[] = {"realms", selRealm, "kdc", NULL};
+        const char** section = Section;
+        char **values = NULL;
+        char * value  = NULL;
+
+        long retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                           section, &values);
+
+        if (!retval && values)
+            m_hostServer = *values;
+        else {
+            int dns_in_use = 0;
+            // Determine if we are using DNS for KDC lookups
+            retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                          "dns_lookup_kdc", 0, 0, &value);
+            if (value == 0 && retval == 0)
+                retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                              "dns_fallback", 0, 0, &value);
+            if (value == 0) {
+#if KRB5_DNS_LOOKUP_KDC
+                dns_in_use = 1;
+#else
+                dns_in_use = 0;
+#endif
+            } else {
+                dns_in_use = config_boolean_to_int(value);
+                pprofile_release_string(value);
+            }
+            if (dns_in_use)
+                m_hostServer = "DNS SRV record lookups will be used to find KDC";
+            else {
+                m_hostServer = "No KDC information available";
+            }
+        }
+        SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_hostServer);
+
+        if ( realm )
+            pkrb5_free_default_realm(CLeashApp::m_krbv5_context, realm);
+    }
+
+       // Set host and domain names in their Edit Boxes, respectively.
+       char hostName[80]="";
+       char domainName[80]="";
+       int ckHost = wsh_gethostname(hostName, sizeof(hostName));
+       int ckdomain = wsh_getdomainname(domainName, sizeof(domainName));
+       CString dot_DomainName = ".";
+       dot_DomainName += domainName;
+
+       SetDlgItemText(IDC_EDIT_HOSTNAME, ckHost == 0 ? hostName : "");
+       SetDlgItemText(IDC_EDIT_DOMAINNAME, ckdomain == 0 ? dot_DomainName : "");
+
+       return m_noRealm;
+}
+
+BOOL CKrbConfigOptions::OnApply()
+{
+       // If no changes were made, quit this function
+       if (0 == m_initDefaultRealm.CompareNoCase(m_newDefaultRealm))
+         return TRUE;
+
+       m_newDefaultRealm.TrimLeft();
+       m_newDefaultRealm.TrimRight();
+
+       if (m_newDefaultRealm.IsEmpty())
+       {
+               MessageBox("OnApply::Your Kerberos Realm field must be filled in!",
+                    "Leash", MB_OK);
+               m_newDefaultRealm = m_initDefaultRealm;
+               SetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newDefaultRealm);
+               return TRUE;
+       }
+
+       CStdioFile krbCon;
+       if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeCreate |
+                         CFile::modeNoTruncate |
+                         CFile::modeRead))
+       {
+               LeashErrorBox("OnApply::Can't open configuration file",
+                                         CKrbProperties::m_krbPath);
+               return TRUE;
+       }
+
+       CStdioFile krbCon2;
+       CString krbCon2File = CKrbProperties::m_krbPath;
+       krbCon2File += "___";
+       if (!krbCon2.Open(krbCon2File, CFile::modeCreate | CFile::modeWrite))
+       {
+               LeashErrorBox("OnApply:: Can't open configuration file",
+                                         CKrbProperties::m_krbPath);
+               return TRUE;
+       }
+
+       CString readWrite;
+       krbCon.ReadString(readWrite);
+       krbCon2.WriteString(m_newDefaultRealm);
+       krbCon2.WriteString("\n");
+       while (krbCon.ReadString(readWrite))
+       {
+               krbCon2.WriteString(readWrite);
+               krbCon2.WriteString("\n");
+       }
+
+       krbCon.Close();
+       krbCon2.Close();
+       krbCon2.Remove(CKrbProperties::m_krbPath);
+       krbCon2.Rename(krbCon2File, CKrbProperties::m_krbPath);
+
+       if (CLeashApp::m_hKrb5DLL)
+       { // Krb5 OR krb5 AND krb4
+           if ( !CLeashApp::m_krbv5_profile ) {
+            CHAR confname[MAX_PATH];
+            if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+            {
+                const char *filenames[2];
+                filenames[0] = confname;
+                filenames[1] = NULL;
+                pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+            }
+           }
+
+               const char*  Names[] = {"libdefaults", "default_realm", NULL};
+               const char** names = Names;
+
+               long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                       names, m_initDefaultRealm, m_newDefaultRealm);
+
+               if (retval)
+               {
+                       MessageBox("OnApply::The previous value cannot be found, the profile will not be saved!!!\
+                        \nIf this error persists after restarting Leash, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return TRUE;
+               }
+
+               // Save to Kerberos Five config. file "Krb5.ini"
+           retval = pprofile_flush(CLeashApp::m_krbv5_profile);
+       }
+
+       m_initDefaultRealm = m_newDefaultRealm;
+       return TRUE;
+}
+
+void CKrbConfigOptions::OnSelchangeEditDefaultRealm()
+{
+       if (!m_startupPage2)
+       {
+               GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newDefaultRealm);
+               SetModified(TRUE);
+
+               if (CLeashApp::m_hKrb5DLL)
+               {
+                       CHAR selRealm[REALM_SZ];
+                       strcpy(selRealm, m_newDefaultRealm);
+                       const char*  Section[] = {"realms", selRealm, "kdc", NULL};
+                       const char** section = Section;
+                       char **values = NULL;
+                       char * value  = NULL;
+
+                       long retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                                                                          section, &values);
+
+                       if (!retval && values)
+                         SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, *values);
+                       else {
+                               int dns_in_use = 0;
+                               // Determine if we are using DNS for KDC lookups
+                               retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                                                        "dns_lookup_kdc", 0, 0, &value);
+                               if (value == 0 && retval == 0)
+                                       retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                                                                "dns_fallback", 0, 0, &value);
+                               if (value == 0) {
+#if KRB5_DNS_LOOKUP_KDC
+                               dns_in_use = 1;
+#else
+                                       dns_in_use = 0;
+#endif
+                               } else {
+                                       dns_in_use = config_boolean_to_int(value);
+                                       pprofile_release_string(value);
+                               }
+                               if (dns_in_use)
+                                       SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, "DNS SRV record lookups will be used to find KDC");
+                               else
+                                       SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, "No KDC information available");
+                       }
+               }
+               else
+               {
+                       CHAR krbhst[MAX_HSTNM + 1];
+                       CHAR krbrlm[REALM_SZ + 1];
+
+                       strcpy(krbrlm, CKrbConfigOptions::m_newDefaultRealm);
+                       memset(krbhst, '\0', sizeof(krbhst));
+
+                       // Check for Host
+                       // don't use KRB4 - krb_get_krbhst - would have to re-logon, on file location
+                       // change, to use this function
+                       if (KFAILURE == pkrb_get_krbhst(krbhst, krbrlm, 1))
+                       {
+                               MessageBox("OnSelchangeEditDefaultRealm::Unable to find the Host Server for your Default Realm!!!\
+                            \n 'Apply' your changes and try again.",
+                                               "Leash", MB_OK);
+                           SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, "");
+                               return;
+                       }
+
+                       m_hostServer = krbhst;
+                       if (strlen(krbhst))
+                         SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_hostServer);
+               }
+       }
+}
+
+void CKrbConfigOptions::OnEditchangeEditDefaultRealm()
+{
+       if (!m_startupPage2)
+       {
+               GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newDefaultRealm);
+               SetModified(TRUE);
+       }
+}
+
+void CKrbConfigOptions::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CPropertyPage::OnShowWindow(bShow, nStatus);
+
+       if (CLeashApp::m_hKrb5DLL)
+         ResetDefaultRealmComboBox();
+
+       SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_hostServer);
+}
+
+void CKrbConfigOptions::ResetDefaultRealmComboBox()
+{ // Krb5 is loaded
+       // Reset Config Tab's Default Realm Combo Editbox
+       const char*  rootSection[] = {"realms", NULL};
+       const char** rootsec = rootSection;
+       char **sections = NULL,
+                **cpp = NULL,
+         *value = 0;
+    int dns;
+
+    long retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                  "dns_lookup_kdc", 0, 0, &value);
+    if (value == 0 && retval == 0)
+        retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                      "dns_fallback", 0, 0, &value);
+    if (value == 0) {
+#if KRB5_DNS_LOOKUP_KDC
+        dns = 1;
+#else
+        dns = 0;
+#endif
+    } else {
+        dns = config_boolean_to_int(value);
+        pprofile_release_string(value);
+    }
+
+    retval = pprofile_get_subsection_names(CLeashApp::m_krbv5_profile,
+                                                   rootsec , &sections);
+
+       if (retval)
+       {
+        m_hostServer = _T("");
+
+        // This is not a fatal error if DNS KDC Lookup is being used.
+        // Determine the starting value for DNS KDC Lookup Checkbox
+        if ( dns )
+            return;
+
+        m_profileError = TRUE;
+       }
+
+       m_krbRealmEditbox.ResetContent();
+
+    if ( !m_profileError ) {
+       for (cpp = sections; *cpp; cpp++)
+       {
+               if (CB_ERR == m_krbRealmEditbox.FindStringExact(-1, *cpp))
+               { // no dups
+                       if (CB_ERR == m_krbRealmEditbox.AddString(*cpp))
+                       {
+                               ::MessageBox(NULL, "ResetDefaultRealmComboBox::Can't add to Kerberos Realm Combobox",
+                                                        "Leash", MB_OK);
+                               return;
+                       }
+               }
+               else
+                 m_dupEntriesError = TRUE;
+       }
+    }
+
+    if (!m_newDefaultRealm.IsEmpty()) {
+
+               if (CB_ERR == m_krbRealmEditbox.FindStringExact(-1, m_newDefaultRealm))
+               { // no dups
+                       m_krbRealmEditbox.AddString(m_newDefaultRealm);
+               }
+               m_krbRealmEditbox.SelectString(-1, m_newDefaultRealm);
+
+               const char*  Section[] = {"realms", m_newDefaultRealm, "kdc", NULL}; //theSection
+               const char** section = Section;
+               char **values = NULL;
+
+               retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                            section, &values);
+
+        if (!retval && values)
+            m_hostServer = *values;
+        else {
+            if (dns)
+                m_hostServer = "DNS SRV record lookups will be used to find KDC";
+            else {
+                m_hostServer = "No KDC information available";
+            }
+               }
+       }
+}
+
+BOOL CKrbConfigOptions::PreTranslateMessage(MSG* pMsg)
+{
+       if (!m_startupPage2)
+       {
+               if (m_noKrbFileError)
+               {
+                       LeashErrorBox("PreTranslateMessage::Unable to open configuration file",
+                               !strlen(CKrbProperties::m_krbPath) ? KRB_FILE :
+                               CKrbProperties::m_krbPath);
+                       m_noKrbFileError = FALSE;
+               }
+
+               if (m_noKrbhostWarning)
+               {
+                       MessageBox("PreTranslateMessage::Unable to locate the Kerberos Host for your Kerberos Realm!",
+                                          "Leash", MB_OK);
+                       m_noKrbhostWarning = FALSE;
+               }
+
+               if (m_dupEntriesError)
+               {
+                       MessageBox("PreTranslateMessage::Found duplicate entries in the Kerberos 5 Config. File!!!\
+                        \nPlease contact your Administrator.",
+                                          "Leash", MB_OK);
+
+                       m_dupEntriesError = FALSE;
+               }
+
+               if (m_profileError)
+               {
+                       MessageBox("PreTranslateMessage::Unable to open Kerberos 5 Config. File!!!\
+                        \nIf this error persists, contact your administrator.",
+                                      "Leash", MB_OK);
+                       m_profileError  = FALSE;
+               }
+
+               if (m_noRealm)
+               {
+                       MessageBox("PreTranslateMessage::Unable to determine the Default Realm.\
+                        \n Contact your Administrator!",
+                                          "Leash", MB_OK);
+
+                       m_noRealm = FALSE;
+               }
+       }
+
+       m_startupPage2 = FALSE;
+       return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbConfigOptions, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrbConfigOptions)
+       ON_WM_SHOWWINDOW()
+       ON_CBN_EDITCHANGE(IDC_EDIT_DEFAULT_REALM, OnEditchangeEditDefaultRealm)
+       ON_CBN_SELCHANGE(IDC_EDIT_DEFAULT_REALM, OnSelchangeEditDefaultRealm)
+       ON_BN_CLICKED(IDC_BUTTON_KRB_HELP, OnButtonKrbHelp)
+       ON_BN_CLICKED(IDC_BUTTON_KRBREALM_HELP, OnButtonKrbrealmHelp)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+
+void CKrbConfigOptions::OnButtonKrbHelp()
+{
+       MessageBox("No Help Available!", "Leash", MB_OK);
+}
+
+void CKrbConfigOptions::OnButtonKrbrealmHelp()
+{
+       MessageBox("No Help Available!", "Leash", MB_OK);
+}
diff --git a/src/windows/leash/KrbConfigOptions.h b/src/windows/leash/KrbConfigOptions.h
new file mode 100644 (file)
index 0000000..3169e71
--- /dev/null
@@ -0,0 +1,89 @@
+//     **************************************************************************************
+//     File:                   KrbConfigOptions.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbProperties.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     2/01/98 ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_CONFIGOPTIONS_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
+#define AFX_CONFIGOPTIONS_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+// Krb4Properties.h : header file
+//
+
+#include "Resource.h"
+
+
+///////////////////////////////////////////////////////////////////////
+// CKrbConfigOptions dialog
+
+class CKrbConfigOptions : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrbConfigOptions)
+       BOOL m_startupPage2;
+       BOOL m_noKrbFileError;
+       BOOL m_noKrbhostWarning;
+       static BOOL m_profileError;
+       static BOOL m_dupEntriesError;
+       BOOL m_noRealm;
+       CString m_initDefaultRealm;
+       static CString m_newDefaultRealm; ///// also used for CKrb4DomainRealmMaintenance
+       static CString m_hostServer;
+
+       static void ResetDefaultRealmComboBox();
+
+public:
+       CKrbConfigOptions();
+       ~CKrbConfigOptions();
+
+// Dialog Data
+       //{{AFX_DATA(CKrbConfigOptions)
+       enum { IDD = IDD_KRB_PROP_CONTENT };
+       static CComboBox m_krbRealmEditbox;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generate virtual function overrides
+       //{{AFX_VIRTUAL(CKrbConfigOptions)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual VOID DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       virtual BOOL OnApply();
+
+// Implementation
+protected:
+       // Generated message map functions
+       //{{AFX_MSG(CKrbConfigOptions)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnEditchangeEditDefaultRealm();
+       afx_msg void OnSelchangeEditDefaultRealm();
+       afx_msg void OnButtonKrbHelp();
+       afx_msg void OnButtonKrbrealmHelp();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_CONFIGOPTIONS_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/KrbDomainRealmMaintenance.cpp b/src/windows/leash/KrbDomainRealmMaintenance.cpp
new file mode 100644 (file)
index 0000000..cb13137
--- /dev/null
@@ -0,0 +1,435 @@
+// CKrbDomainRealmMaintenance.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbDomainRealmMaintenance.h"
+#include "Krb4AddToDomainRealmList.h"
+#include "Krb4EditDomainRealmList.h"
+#include "KrbProperties.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbDomainRealmMaintenance dialog
+
+
+CKrbDomainRealmMaintenance::CKrbDomainRealmMaintenance(CWnd* pParent /*=NULL*/)
+       :CPropertyPage(CKrbDomainRealmMaintenance::IDD)
+{
+       m_dupEntiesError = FALSE;
+       //{{AFX_DATA_INIT(CKrbDomainRealmMaintenance)
+       // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CKrbDomainRealmMaintenance::DoDataExchange(CDataExchange* pDX)
+{
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbDomainRealmMaintenance)
+       DDX_Control(pDX, IDC_LIST_DOMAINREALM, m_KDCDomainList);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbDomainRealmMaintenance, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrbDomainRealmMaintenance)
+       ON_BN_CLICKED(IDC_BUTTON_HOST_ADD, OnButtonHostAdd)
+       ON_BN_CLICKED(IDC_BUTTON_HOST_EDIT, OnButtonHostEdit)
+       ON_BN_CLICKED(ID_BUTTON_HOST_REMOVE, OnButtonHostRemove)
+       ON_LBN_DBLCLK(IDC_LIST_DOMAINREALM, OnDblclkListDomainrealm)
+       ON_BN_CLICKED(IDC_BUTTON_HOSTMAINT_HELP, OnButtonHostmaintHelp)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbDomainRealmMaintenance message handlers
+
+BOOL CKrbDomainRealmMaintenance::OnInitDialog()
+{
+       CPropertyPage::OnInitDialog();
+
+       char theName[REALM_SZ + 1];
+       char theNameValue[REALM_SZ + MAX_HSTNM + 2];
+       const char*  Section[] = {"domain_realm", theName, NULL}; //theSection
+       const char** section = Section;
+       char **values = NULL,
+                **vpp = NULL;
+
+       const char*  rootSection[] = {"domain_realm", NULL};
+       const char** rootsec = rootSection;
+       char **sections = NULL,
+                **cpp = NULL;
+
+       long retval = pprofile_get_relation_names(CLeashApp::m_krbv5_profile,
+                                                                                          rootsec, &sections);
+
+       if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnInitDialog::There is on error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return TRUE;
+       }
+
+
+       for (cpp = sections; *cpp; cpp++)
+       {
+               strcpy(theName, *cpp);
+               retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                                                         section, &values);
+
+               for (vpp = values; *vpp; vpp++)
+               {
+                       strcpy(theNameValue, theName);
+                       strcat(theNameValue, " ");
+                       strcat(theNameValue, *vpp);
+
+                       if (LB_ERR == m_KDCDomainList.FindStringExact(-1, theNameValue))
+                       {
+                               if (LB_ERR == m_KDCDomainList.AddString(theNameValue))
+                               {
+                                       MessageBox("OnInitDialog::Can't add to Kerberos Domain Listbox",
+                                                          "Leash", MB_OK);
+                                       return FALSE;
+                               }
+                       }
+                       else
+                         m_dupEntiesError = TRUE;
+               }
+       }
+
+       m_KDCDomainList.SetCurSel(0);
+
+       if (!m_KDCDomainList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       return TRUE;  // return TRUE unless you set the focus to a control
+                     // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+BOOL CKrbDomainRealmMaintenance::OnApply()
+{
+       if (!CLeashApp::m_krbv5_profile) {
+               CHAR confname[MAX_PATH];
+               if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+        {
+               const char *filenames[2];
+                   filenames[0] = confname;
+                       filenames[1] = NULL;
+                       pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+               }
+       }
+
+       // Save to Kerberos Five config. file "Krb5.ini"
+       long retval = pprofile_flush(CLeashApp::m_krbv5_profile);
+
+       if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnApply::There is on error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return TRUE;
+       }
+
+       // Save to Kerberos Four config. file "Krb.con"
+       CStdioFile krbrealmCon;
+       if (!krbrealmCon.Open(CKrbProperties::m_krbrealmPath, CFile::modeCreate |
+                             CFile::modeNoTruncate |
+                                                                                                        CFile::modeReadWrite))
+       {
+               LeashErrorBox("OnApply::Can't open Configuration File",
+                                         CKrbProperties::m_krbrealmPath);
+               return TRUE;
+       }
+
+       krbrealmCon.SetLength(0);
+
+       char theNameValue[REALM_SZ + MAX_HSTNM + 2];
+
+       for (INT maxItems = m_KDCDomainList.GetCount(), item = 0; item < maxItems; item++)
+       {
+               if (LB_ERR == m_KDCDomainList.GetText(item, theNameValue))
+                 ASSERT(0);
+
+               krbrealmCon.WriteString(theNameValue);
+               krbrealmCon.WriteString("\n");
+       }
+
+       krbrealmCon.Close();
+       return TRUE;
+}
+
+void CKrbDomainRealmMaintenance::OnCancel()
+{
+    CHAR fileName[MAX_PATH];
+
+    if (CLeashApp::GetProfileFile(fileName, sizeof(fileName)))
+    {
+        MessageBox("Can't locate Kerberos Five Config. file!", "Error", MB_OK);
+        return;
+    }
+
+    pprofile_abandon(CLeashApp::m_krbv5_profile);
+
+    const char *filenames[2];
+    filenames[0] = fileName;
+    filenames[1] = NULL;
+       pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+
+       CPropertyPage::OnCancel();
+}
+
+void CKrbDomainRealmMaintenance::OnButtonHostAdd()
+{
+       CKrb4AddToDomainRealmList addToDomainRealmList;
+       if (IDOK == addToDomainRealmList.DoModal())
+       {
+               char theName[MAX_HSTNM + 1];
+               const char* Section[] = {"domain_realm", theName, NULL};
+               const char** section = Section;
+
+               if (addToDomainRealmList.GetNewRealm().IsEmpty())
+                 ASSERT(0);
+
+               if (CheckForDupDomain(addToDomainRealmList.GetNewDomainHost()))
+               {
+                       MessageBox("Can't have duplicate Host/Domains!\nYour entry will not be saved to list",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               CString newLine;
+               newLine = addToDomainRealmList.GetNewDomainHost() + " " + addToDomainRealmList.GetNewRealm();
+
+               if (LB_ERR != m_KDCDomainList.FindStringExact(-1, newLine))
+               {
+                       MessageBox("We can't have duplicates!\nYour entry was not saved to list.",
+                        "Leash", MB_OK);
+                       return;
+               }
+
+               CString newHost; // new section in the profile linklist
+               strcpy(theName, addToDomainRealmList.GetNewDomainHost());
+
+               long retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                                section, addToDomainRealmList.GetNewRealm());
+
+               if (retval)
+               {
+                       MessageBox("OnButtonHostAdd::There is on error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                      "Leash", MB_OK);
+               }
+
+               m_KDCDomainList.AddString(newLine);
+               SetModified(TRUE);
+
+               if (1 == m_KDCDomainList.GetCount())
+               {
+                       GetDlgItem(ID_BUTTON_HOST_REMOVE)->EnableWindow();
+                       GetDlgItem(IDC_BUTTON_HOST_EDIT)->EnableWindow();
+               }
+       }
+
+}
+
+void CKrbDomainRealmMaintenance::OnButtonHostEdit()
+{
+       INT selItemIndex = m_KDCDomainList.GetCurSel();
+       LPSTR pSelItem = new char[m_KDCDomainList.GetTextLen(selItemIndex) + 1];
+       if (!pSelItem)
+         ASSERT(0);
+
+       CHAR theName[MAX_HSTNM + 1];
+       char theNameValue[REALM_SZ + MAX_HSTNM + 2];
+       CHAR OLD_VALUE[REALM_SZ + 1];
+       m_KDCDomainList.GetText(selItemIndex, theName);
+       strcpy(pSelItem, theName);
+
+       LPSTR pselItem = strchr(theName, ' ');
+       if (pselItem)
+         *pselItem = 0;
+       else
+         ASSERT(0);
+
+       strcpy(OLD_VALUE, pselItem + 1);
+       strcpy(theNameValue, pSelItem);
+
+       CKrb4EditDomainRealmList editDomainRealmList(pSelItem);
+
+       if (IDOK == editDomainRealmList.DoModal())
+       {
+               if (0 != strcmp(theName, editDomainRealmList.GetDomainHost())
+                       && CheckForDupDomain(editDomainRealmList.GetDomainHost()))
+               { // Duplicate Host/Domain Error
+                       MessageBox("We can't have duplicate Host/Domains!\nYour entry will not be saved to list",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               const char* Section[] = {"domain_realm", theName, NULL};
+               const char** section = Section;
+
+               CString editedHost = editDomainRealmList.GetEditedItem();
+
+               if (0 != editedHost.CompareNoCase(theNameValue) &&
+                       LB_ERR != m_KDCDomainList.FindStringExact(-1, editedHost))
+               {
+                       MessageBox("We can't have duplicate Realms!\nYour entry was not saved to list.",
+                        "Leash", MB_OK);
+                       delete [] pSelItem;
+                       return;
+               }
+
+               long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                                       section, OLD_VALUE,     NULL);
+
+               if (retval)
+               {
+                       MessageBox("OnButtonHostEdit::There is on error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               strcpy(theName, editDomainRealmList.GetDomainHost());
+
+               retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                               section, editDomainRealmList.GetRealm());
+
+
+               if (retval)
+               { // thsi might not be the best way to handle this type of error
+                       MessageBox("OnButtonHostEdit::There is on error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               m_KDCDomainList.DeleteString(selItemIndex);
+               m_KDCDomainList.AddString(editedHost);
+               selItemIndex = m_KDCDomainList.FindStringExact(-1, editedHost);
+               m_KDCDomainList.SetCurSel(selItemIndex);
+
+               SetModified(TRUE);
+       }
+
+       delete [] pSelItem;
+}
+
+void CKrbDomainRealmMaintenance::OnDblclkListDomainrealm()
+{
+       OnButtonHostEdit();
+}
+
+void CKrbDomainRealmMaintenance::OnButtonHostRemove()
+{
+       CHAR theName[MAX_HSTNM + 1];
+       CHAR OLD_VALUE[REALM_SZ + 1];
+       char theNameValue[REALM_SZ + MAX_HSTNM + 2];
+       const char* Section[] = {"domain_realm", theName, NULL};
+       const char** section = Section;
+
+       INT curSel = m_KDCDomainList.GetCurSel();
+       m_KDCDomainList.GetText(curSel, theNameValue);
+
+       CString serverHostMsg;
+       CString serverHost;
+       serverHostMsg.Format("Your about to remove Host/Domain \"%s\" from the list!\n\nContinue?",
+                                                 theNameValue);
+
+       if (IDYES != AfxMessageBox(serverHostMsg, MB_YESNO))
+         return;
+
+       LPSTR pNameValue = strchr(theNameValue, ' ');
+       if (pNameValue)
+       {
+               *pNameValue = 0;
+               strcpy(theName, theNameValue);
+               pNameValue++;
+               strcpy(OLD_VALUE, pNameValue);
+       }
+       else
+         ASSERT(0);
+
+       if (!m_KDCDomainList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_HOSTNAME_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_HOSTNAME_EDIT)->EnableWindow(FALSE);
+       }
+
+       long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                                   section, OLD_VALUE, NULL);
+
+       if (retval)
+       {
+               MessageBox("OnButtonHostRemove::There is on error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+       m_KDCDomainList.DeleteString(curSel);  // Single Sel Listbox
+
+       if (-1 == m_KDCDomainList.SetCurSel(curSel))
+         m_KDCDomainList.SetCurSel(curSel - 1);
+
+       if (!m_KDCDomainList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_HOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_HOST_EDIT)->EnableWindow(FALSE);
+       }
+
+       SetModified(TRUE);
+}
+
+
+BOOL CKrbDomainRealmMaintenance::PreTranslateMessage(MSG* pMsg)
+{
+       if (m_dupEntiesError)
+       {
+               MessageBox("Found an error (duplicate items) in your Kerberos Five Config. File!!!\
+                    \nPlease contract your Administrator.",
+                                  "Leash", MB_OK);
+
+               m_dupEntiesError = FALSE;
+       }
+
+       return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+BOOL CKrbDomainRealmMaintenance::CheckForDupDomain(CString& newDomainHost)
+{
+       char theName[REALM_SZ + MAX_HSTNM + 2];
+
+       for (INT maxItems = m_KDCDomainList.GetCount(), item = 0; item < maxItems; item++)
+       {
+               if (LB_ERR == m_KDCDomainList.GetText(item, theName))
+                 ASSERT(0);
+
+               LPSTR pValue = strchr(theName, ' ');
+               if (pValue)
+                 *pValue = 0;
+               else
+                 ASSERT(0);
+
+               if (0 == newDomainHost.CompareNoCase(theName))
+                 return TRUE;
+       }
+
+       return FALSE;
+}
+
+void CKrbDomainRealmMaintenance::OnButtonHostmaintHelp()
+{
+       MessageBox("No Help Available!", "Leash", MB_OK);
+}
diff --git a/src/windows/leash/KrbDomainRealmMaintenance.h b/src/windows/leash/KrbDomainRealmMaintenance.h
new file mode 100644 (file)
index 0000000..e22e86e
--- /dev/null
@@ -0,0 +1,59 @@
+#if !defined(AFX_KRBDOMAINREALMMAINTENANCE_H__6DB290A6_E14D_11D2_95CE_0000861B8A3C__INCLUDED_)
+#define AFX_KRBDOMAINREALMMAINTENANCE_H__6DB290A6_E14D_11D2_95CE_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// CKrbDomainRealmMaintenance.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbDomainRealmMaintenance dialog
+
+class CKrbDomainRealmMaintenance : public CPropertyPage
+{
+// Construction
+private:
+       BOOL m_dupEntiesError;
+       BOOL CheckForDupDomain(CString& newDomainHost);
+
+public:
+       CKrbDomainRealmMaintenance(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CKrbDomainRealmMaintenance)
+       enum { IDD = IDD_KRB_DOMAINREALM_MAINT };
+       CListBox        m_KDCDomainList;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbDomainRealmMaintenance)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbDomainRealmMaintenance)
+       virtual void OnCancel();
+       virtual BOOL OnApply();
+       virtual BOOL OnInitDialog();
+       afx_msg void OnButtonHostAdd();
+       afx_msg void OnButtonHostEdit();
+       afx_msg void OnButtonHostRemove();
+       afx_msg void OnDblclkListDomainrealm();
+       afx_msg void OnButtonHostmaintHelp();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRBDOMAINREALMMAINTENANCE_H__6DB290A6_E14D_11D2_95CE_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbEditHostServer.cpp b/src/windows/leash/KrbEditHostServer.cpp
new file mode 100644 (file)
index 0000000..4245c2b
--- /dev/null
@@ -0,0 +1,97 @@
+//     **************************************************************************************
+//     File:                   KrbEditHostServer.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbEditHostServer.h. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4Properties.h"
+#include "KrbEditHostServer.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditHostServer dialog
+
+CKrbEditHostServer::CKrbEditHostServer(CString& editItem, CWnd* pParent)
+       : CDialog(CKrbEditHostServer::IDD, pParent)
+{
+       m_startup = TRUE;
+       m_newHost = editItem;
+
+       //{{AFX_DATA_INIT(CKrbEditHostServer)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+void CKrbEditHostServer::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbEditHostServer)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbEditHostServer, CDialog)
+       //{{AFX_MSG_MAP(CKrbEditHostServer)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_KDC_HOST, OnChangeEditKdcHost)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditHostServer message handlers
+
+BOOL CKrbEditHostServer::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       SetDlgItemText(IDC_EDIT_KDC_HOST, m_newHost);
+       return TRUE;
+}
+
+void CKrbEditHostServer::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+void CKrbEditHostServer::OnChangeEditKdcHost()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_KDC_HOST, m_newHost);
+}
+
+void CKrbEditHostServer::OnOK()
+{
+       m_newHost.TrimLeft();
+       m_newHost.TrimRight();
+
+       if (m_newHost.IsEmpty())
+       { // stay
+               MessageBox("OnOK::The Server field must be filled in!",
+                    "Error", MB_OK);
+       }
+       else if (-1 != m_newHost.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Error", MB_OK);
+       }
+       else
+         CDialog::OnOK(); // exit
+}
diff --git a/src/windows/leash/KrbEditHostServer.h b/src/windows/leash/KrbEditHostServer.h
new file mode 100644 (file)
index 0000000..5cbbd03
--- /dev/null
@@ -0,0 +1,69 @@
+//     **************************************************************************************
+//     File:                   KrbEditHostServer.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbEditHostServer.cpp. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#if !defined(AFX_EDITHOST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
+#define AFX_EDITHOST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EditRealmHostList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditHostServer dialog
+
+class CKrbEditHostServer : public CDialog
+{
+// Construction
+private:
+       CString m_newHost;
+       BOOL m_startup;
+
+public:
+       CKrbEditHostServer(CString& editItem, CWnd* pParent = NULL);
+       CString GetEditedItem() {return m_newHost;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrbEditHostServer)
+       enum { IDD = IDD_KRB_EDIT_KDC_HOSTSERVER };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbEditHostServer)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbEditHostServer)
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       virtual void OnOK();
+       virtual BOOL OnInitDialog();
+       afx_msg void OnChangeEditKdcHost();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EDITHOST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbEditRealm.cpp b/src/windows/leash/KrbEditRealm.cpp
new file mode 100644 (file)
index 0000000..caa1e15
--- /dev/null
@@ -0,0 +1,99 @@
+//     **************************************************************************************
+//     File:                   KrbEditRealm.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbEditRealm.h. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "Krb4Properties.h"
+#include "KrbEditRealm.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditRealm dialog
+
+CKrbEditRealm::CKrbEditRealm(CString& editItem, CWnd* pParent)
+       : CDialog(CKrbEditRealm::IDD, pParent)
+{
+       m_startup = TRUE;
+       m_newRealm = editItem;
+
+
+       //{{AFX_DATA_INIT(CKrbEditRealm)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+void CKrbEditRealm::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbEditRealm)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbEditRealm, CDialog)
+       //{{AFX_MSG_MAP(CKrbEditRealm)
+       ON_WM_SHOWWINDOW()
+       ON_EN_CHANGE(IDC_EDIT_REALM, OnChangeEditRealm)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditRealm message handlers
+
+BOOL CKrbEditRealm::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       SetDlgItemText(IDC_EDIT_REALM, m_newRealm);
+
+       return TRUE;
+}
+
+void CKrbEditRealm::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+       m_startup = FALSE;
+}
+
+void CKrbEditRealm::OnChangeEditRealm()
+{
+       if (!m_startup)
+         GetDlgItemText(IDC_EDIT_REALM, m_newRealm);
+}
+
+void CKrbEditRealm::OnOK()
+{
+       m_newRealm.TrimLeft();
+       m_newRealm.TrimRight();
+
+       if (m_newRealm.IsEmpty())
+       { // stay
+               MessageBox("OnOK::The Realm field must be filled in!",
+                    "Leash", MB_OK);
+       }
+       else if (-1 != m_newRealm.Find(' '))
+       { // stay
+               MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
+       }
+       else
+         CDialog::OnOK(); // exit
+}
diff --git a/src/windows/leash/KrbEditRealm.h b/src/windows/leash/KrbEditRealm.h
new file mode 100644 (file)
index 0000000..4bf5fdf
--- /dev/null
@@ -0,0 +1,75 @@
+//     **************************************************************************************
+//     File:                   KrbEditRealm.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Krb4EditRealmHostList.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#if !defined(AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
+#define AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EditRealmHostList.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbEditRealm dialog
+
+class CKrbEditRealm : public CDialog
+{
+// Construction
+private:
+       //CString m_editItem;
+       //CString m_initRealm;
+       CString m_newRealm;
+       //CString m_initHost;
+       //CString m_newHost;
+       //BOOL m_initAdmin;
+       //BOOL m_newAdmin;
+       BOOL m_startup;
+
+public:
+       CKrbEditRealm(CString& editItem, CWnd* pParent = NULL);
+       CString GetEditedItem() {return m_newRealm;}
+
+// Dialog Data
+       //{{AFX_DATA(CKrbEditRealm)
+       enum { IDD = IDD_KRB_EDIT_REALM };
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbEditRealm)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbEditRealm)
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnChangeEditRealm();
+       virtual void OnOK();
+       virtual BOOL OnInitDialog();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EDITREALMHOSTLIST_H__26A1E1F7_9117_11D2_94D0_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/KrbMiscConfigOpt.cpp b/src/windows/leash/KrbMiscConfigOpt.cpp
new file mode 100644 (file)
index 0000000..cdb4c67
--- /dev/null
@@ -0,0 +1,1012 @@
+//*****************************************************************************
+// File:       KrbMiscConfigOpt.cpp
+// By:         Paul B. Hill
+// Created:    08/12/1999
+// Copyright:  @1999 Massachusetts Institute of Technology - All rights
+//             reserved.
+// Description: CPP file for KrbMiscConfigOpt.cpp.  Contains variables
+//             and functions for Kerberos Properties.
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 08/12/99    PBH     Original
+//*****************************************************************************
+
+#include "stdafx.h"
+#include "Leash.h"
+#include "KrbProperties.h"
+#include "KrbMiscConfigOpt.h"
+#include "LeashFileDialog.h"
+#include "LeashMessageBox.h"
+#include "lglobals.h"
+#include <direct.h>
+#include "reminder.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+///////////////////////////////////////////////////////////////////////
+// CKrbMiscConfigOpt property page
+
+UINT CKrbMiscConfigOpt::m_DefaultLifeTime;
+CString CKrbMiscConfigOpt::m_initDefaultLifeTimeMin;
+CString CKrbMiscConfigOpt::m_newDefaultLifeTimeMin;
+CEdit CKrbMiscConfigOpt::m_krbLifeTimeMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeTimeHr;
+CString CKrbMiscConfigOpt::m_newDefaultLifeTimeHr;
+CEdit CKrbMiscConfigOpt::m_krbLifeTimeHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeTimeDay;
+CString CKrbMiscConfigOpt::m_newDefaultLifeTimeDay;
+CEdit CKrbMiscConfigOpt::m_krbLifeTimeDayEditbox;
+
+UINT CKrbMiscConfigOpt::m_DefaultRenewTill;
+CString CKrbMiscConfigOpt::m_initDefaultRenewTillMin;
+CString CKrbMiscConfigOpt::m_newDefaultRenewTillMin;
+CEdit CKrbMiscConfigOpt::m_krbRenewTillMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewTillHr;
+CString CKrbMiscConfigOpt::m_newDefaultRenewTillHr;
+CEdit CKrbMiscConfigOpt::m_krbRenewTillHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewTillDay;
+CString CKrbMiscConfigOpt::m_newDefaultRenewTillDay;
+CEdit CKrbMiscConfigOpt::m_krbRenewTillDayEditbox;
+
+UINT CKrbMiscConfigOpt::m_DefaultLifeMin;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMinMin;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMinMin;
+CEdit CKrbMiscConfigOpt::m_krbLifeMinMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMinHr;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMinHr;
+CEdit CKrbMiscConfigOpt::m_krbLifeMinHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMinDay;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMinDay;
+CEdit CKrbMiscConfigOpt::m_krbLifeMinDayEditbox;
+
+UINT CKrbMiscConfigOpt::m_DefaultLifeMax;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMaxMin;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMaxMin;
+CEdit CKrbMiscConfigOpt::m_krbLifeMaxMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMaxHr;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMaxHr;
+CEdit CKrbMiscConfigOpt::m_krbLifeMaxHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultLifeMaxDay;
+CString CKrbMiscConfigOpt::m_newDefaultLifeMaxDay;
+CEdit CKrbMiscConfigOpt::m_krbLifeMaxDayEditbox;
+
+UINT CKrbMiscConfigOpt::m_DefaultRenewMin;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMinMin;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMinMin;
+CEdit CKrbMiscConfigOpt::m_krbRenewMinMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMinHr;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMinHr;
+CEdit CKrbMiscConfigOpt::m_krbRenewMinHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMinDay;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMinDay;
+CEdit CKrbMiscConfigOpt::m_krbRenewMinDayEditbox;
+
+UINT CKrbMiscConfigOpt::m_DefaultRenewMax;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMaxMin;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMaxMin;
+CEdit CKrbMiscConfigOpt::m_krbRenewMaxMinEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMaxHr;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMaxHr;
+CEdit CKrbMiscConfigOpt::m_krbRenewMaxHrEditbox;
+CString CKrbMiscConfigOpt::m_initDefaultRenewMaxDay;
+CString CKrbMiscConfigOpt::m_newDefaultRenewMaxDay;
+CEdit CKrbMiscConfigOpt::m_krbRenewMaxDayEditbox;
+
+
+IMPLEMENT_DYNCREATE(CKrbMiscConfigOpt, CPropertyPage)
+
+CKrbMiscConfigOpt::CKrbMiscConfigOpt() : CPropertyPage(CKrbMiscConfigOpt::IDD)
+{
+    m_noLifeTime = FALSE;
+
+    m_DefaultLifeTime = 0;
+    m_DefaultRenewTill = 0;
+       m_DefaultLifeMin = 0;
+       m_DefaultLifeMax = 0;
+       m_DefaultRenewMin = 0;
+       m_DefaultRenewMax = 0;
+    m_initUseKrb4 = m_newUseKrb4 = 0;
+    m_initKinitPreserve = m_newKinitPreserve = 0;
+
+       //{{AFX_DATA_INIT(CKrbConfigOptions)
+       //}}AFX_DATA_INIT
+}
+
+CKrbMiscConfigOpt::~CKrbMiscConfigOpt()
+{
+}
+
+VOID CKrbMiscConfigOpt::DoDataExchange(CDataExchange* pDX)
+{
+    TRACE("Entering CKrbMiscConfigOpt::DoDataExchange -- %d\n",
+          pDX->m_bSaveAndValidate);
+    CPropertyPage::DoDataExchange(pDX);
+    //{{AFX_DATA_MAP(CKrbMscConfigOpt)
+
+    DDX_Control(pDX, IDC_EDIT_LIFETIME_D,  m_krbLifeTimeDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFETIME_H,  m_krbLifeTimeHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFETIME_M,  m_krbLifeTimeMinEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEWTILL_D,  m_krbRenewTillDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEWTILL_H,  m_krbRenewTillHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEWTILL_M,  m_krbRenewTillMinEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MIN_D,  m_krbLifeMinDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MIN_H,  m_krbLifeMinHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MIN_M,  m_krbLifeMinMinEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MAX_D,  m_krbLifeMaxDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MAX_H,  m_krbLifeMaxHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_LIFE_MAX_M,  m_krbLifeMaxMinEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MIN_D, m_krbRenewMinDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MIN_H, m_krbRenewMinHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MIN_M, m_krbRenewMinMinEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MAX_D, m_krbRenewMaxDayEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MAX_H, m_krbRenewMaxHrEditbox);
+    DDX_Control(pDX, IDC_EDIT_RENEW_MAX_M, m_krbRenewMaxMinEditbox);
+    //}}AFX_DATA_MAP
+}
+
+
+BOOL CKrbMiscConfigOpt::OnInitDialog()
+{
+    CPropertyPage::OnInitDialog();
+
+       DWORD tmp = m_DefaultLifeTime = pLeash_get_default_lifetime();
+    if (tmp)
+        m_noLifeTime = FALSE; // We now have the value.
+    else
+        m_noLifeTime = TRUE;
+
+    LPTSTR buf = m_initDefaultLifeTimeDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultLifeTimeDay.ReleaseBuffer();
+       m_newDefaultLifeTimeDay = m_initDefaultLifeTimeDay;
+
+       buf = m_initDefaultLifeTimeHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultLifeTimeHr.ReleaseBuffer();
+       m_newDefaultLifeTimeHr = m_initDefaultLifeTimeHr;
+
+       buf = m_initDefaultLifeTimeMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultLifeTimeMin.ReleaseBuffer();
+       m_newDefaultLifeTimeMin = m_initDefaultLifeTimeMin;
+
+       tmp = m_DefaultRenewTill = pLeash_get_default_renew_till();
+    buf = m_initDefaultRenewTillDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultRenewTillDay.ReleaseBuffer();
+       m_newDefaultRenewTillDay = m_initDefaultRenewTillDay;
+
+       buf = m_initDefaultRenewTillHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultRenewTillHr.ReleaseBuffer();
+       m_newDefaultRenewTillHr = m_initDefaultRenewTillHr;
+
+       buf = m_initDefaultRenewTillMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultRenewTillMin.ReleaseBuffer();
+       m_newDefaultRenewTillMin = m_initDefaultRenewTillMin;
+
+    tmp = m_DefaultLifeMin = pLeash_get_default_life_min();
+       buf = m_initDefaultLifeMinDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultLifeMinDay.ReleaseBuffer();
+       m_newDefaultLifeMinDay = m_initDefaultLifeMinDay;
+
+       buf = m_initDefaultLifeMinHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultLifeMinHr.ReleaseBuffer();
+       m_newDefaultLifeMinHr = m_initDefaultLifeMinHr;
+
+       buf = m_initDefaultLifeMinMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultLifeMinMin.ReleaseBuffer();
+       m_newDefaultLifeMinMin = m_initDefaultLifeMinMin;
+
+       tmp = m_DefaultLifeMax = pLeash_get_default_life_max();
+       buf = m_initDefaultLifeMaxDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultLifeMaxDay.ReleaseBuffer();
+       m_newDefaultLifeMaxDay = m_initDefaultLifeMaxDay;
+
+       buf = m_initDefaultLifeMaxHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultLifeMaxHr.ReleaseBuffer();
+       m_newDefaultLifeMaxHr = m_initDefaultLifeMaxHr;
+
+       buf = m_initDefaultLifeMaxMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultLifeMaxMin.ReleaseBuffer();
+       m_newDefaultLifeMaxMin = m_initDefaultLifeMaxMin;
+
+    tmp = m_DefaultRenewMin = pLeash_get_default_renew_min();
+       buf = m_initDefaultRenewMinDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultRenewMinDay.ReleaseBuffer();
+       m_newDefaultRenewMinDay = m_initDefaultRenewMinDay;
+
+       buf = m_initDefaultRenewMinHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultRenewMinHr.ReleaseBuffer();
+       m_newDefaultRenewMinHr = m_initDefaultRenewMinHr;
+
+       buf = m_initDefaultRenewMinMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultRenewMinMin.ReleaseBuffer();
+       m_newDefaultRenewMinMin = m_initDefaultRenewMinMin;
+
+       tmp = m_DefaultRenewMax = pLeash_get_default_renew_max();
+       buf = m_initDefaultRenewMaxDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_initDefaultRenewMaxDay.ReleaseBuffer();
+       m_newDefaultRenewMaxDay = m_initDefaultRenewMaxDay;
+
+       buf = m_initDefaultRenewMaxHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_initDefaultRenewMaxHr.ReleaseBuffer();
+       m_newDefaultRenewMaxHr = m_initDefaultRenewMaxHr;
+
+       buf = m_initDefaultRenewMaxMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_initDefaultRenewMaxMin.ReleaseBuffer();
+       m_newDefaultRenewMaxMin = m_initDefaultRenewMaxMin;
+
+    if (!CLeashApp::m_hKrb5DLL)
+    {
+        GetDlgItem(IDC_EDIT_RENEWTILL_D)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEWTILL_H)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEWTILL_M)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MIN_D)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MIN_H)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MIN_M)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MAX_D)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MAX_H)->EnableWindow(FALSE);
+        GetDlgItem(IDC_EDIT_RENEW_MAX_M)->EnableWindow(FALSE);
+    }
+
+
+    m_initUseKrb4 = m_newUseKrb4 = (CLeashApp::m_hKrb4DLL ? pLeash_get_default_use_krb4() : 0);
+       CheckDlgButton(IDC_CHECK_REQUEST_KRB4, m_initUseKrb4);
+    if ( !CLeashApp::m_hKrb4DLL )
+        GetDlgItem(IDC_CHECK_REQUEST_KRB4)->EnableWindow(FALSE);
+
+    m_initKinitPreserve = m_newKinitPreserve = pLeash_get_default_preserve_kinit_settings();
+       CheckDlgButton(IDC_CHECK_PRESERVE_KINIT_OPTIONS, m_initKinitPreserve);
+
+    return(TRUE);
+}
+
+BOOL CKrbMiscConfigOpt::OnApply()
+{
+    DWORD lifetime = ((atoi(m_newDefaultLifeTimeDay)*24 + atoi(m_newDefaultLifeTimeHr)) * 60) + atoi(m_newDefaultLifeTimeMin);
+    DWORD renewtill = ((atoi(m_newDefaultRenewTillDay)*24 + atoi(m_newDefaultRenewTillHr)) * 60) + atoi(m_newDefaultRenewTillMin);
+    DWORD lifemin = ((atoi(m_newDefaultLifeMinDay)*24 + atoi(m_newDefaultLifeMinHr)) * 60) + atoi(m_newDefaultLifeMinMin);
+    DWORD lifemax = ((atoi(m_newDefaultLifeMaxDay)*24 + atoi(m_newDefaultLifeMaxHr)) * 60) + atoi(m_newDefaultLifeMaxMin);
+    DWORD renewmin = ((atoi(m_newDefaultRenewMinDay)*24 + atoi(m_newDefaultRenewMinHr)) * 60) + atoi(m_newDefaultRenewMinMin);
+    DWORD renewmax = ((atoi(m_newDefaultRenewMaxDay)*24 + atoi(m_newDefaultRenewMaxHr)) * 60) + atoi(m_newDefaultRenewMaxMin);
+
+    // If no changes were made, quit this function
+    if ( m_DefaultLifeTime == lifetime &&
+         m_DefaultRenewTill == renewtill &&
+                m_DefaultLifeMin == lifemin &&
+                m_DefaultLifeMax == lifemax &&
+                m_DefaultRenewMin == renewmin &&
+                m_DefaultRenewMax == renewmax &&
+                m_initUseKrb4 == m_newUseKrb4 &&
+                m_initKinitPreserve == m_newKinitPreserve
+                )
+        return TRUE;
+
+    if ( lifemin > lifemax ) {
+        MessageBox("The Minimum Ticket Lifetime must be less than the Maximum Ticket Lifetime.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if (lifetime < lifemin || lifetime > lifemax) {
+        MessageBox("The default Ticket Lifetime must fall within the range specified by the "
+                   "Minimum and Maximum Ticket Lifetime fields",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if ( CLeashApp::m_hKrb5DLL && (renewmin > renewmax) ) {
+        MessageBox("The Minimum Ticket Renewable Lifetime must be less than the Maximum Ticket Renewable Lifetime.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    if ( CLeashApp::m_hKrb5DLL && (renewmin < lifemin) ) {
+        MessageBox("The Minimum Renewable Ticket Lifetime must not be smaller than the Minimum Ticket Lifetime.",
+                    "Leash", MB_OK);
+    }
+
+    if ( CLeashApp::m_hKrb5DLL && (renewtill < renewmin || renewtill > renewmax) ) {
+        MessageBox("The default Renewable Ticket Lifetime must fall within the range specified by the "
+                   "Minimum and Maximum Renewable Ticket Lifetime fields",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+       m_DefaultLifeMin = lifemin;
+       pLeash_set_default_life_min(m_DefaultLifeMin);
+       m_initDefaultLifeMinDay = m_newDefaultLifeMinDay;
+       m_initDefaultLifeMinHr  = m_newDefaultLifeMinHr ;
+       m_initDefaultLifeMinMin = m_newDefaultLifeMinMin;
+
+       m_DefaultLifeMax = lifemax;
+       pLeash_set_default_life_max(m_DefaultLifeMax);
+       m_initDefaultLifeMaxDay = m_newDefaultLifeMaxDay;
+       m_initDefaultLifeMaxHr  = m_newDefaultLifeMaxHr ;
+       m_initDefaultLifeMaxMin = m_newDefaultLifeMaxMin;
+
+       m_DefaultRenewMin = renewmin;
+       pLeash_set_default_renew_min(m_DefaultRenewMin);
+       m_initDefaultRenewMinDay = m_newDefaultRenewMinDay;
+       m_initDefaultRenewMinHr  = m_newDefaultRenewMinHr ;
+       m_initDefaultRenewMinMin = m_newDefaultRenewMinMin;
+
+       m_DefaultRenewMax = renewmax;
+       pLeash_set_default_renew_max(m_DefaultRenewMax);
+       m_initDefaultRenewMaxDay = m_newDefaultRenewMaxDay;
+       m_initDefaultRenewMaxHr  = m_newDefaultRenewMaxHr ;
+       m_initDefaultRenewMaxMin = m_newDefaultRenewMaxMin;
+
+    m_DefaultRenewTill = renewtill;
+       pLeash_set_default_renew_till(m_DefaultRenewTill);
+       m_initDefaultRenewTillDay = m_newDefaultRenewTillDay;
+       m_initDefaultRenewTillHr  = m_newDefaultRenewTillHr ;
+       m_initDefaultRenewTillMin = m_newDefaultRenewTillMin;
+
+    if( getenv("LIFETIME") !=  NULL)
+    {
+        MessageBox("The ticket lifetime is being controlled by the environment "
+                   "variable LIFETIME instead of the registry. Leash cannot modify "
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return(FALSE);
+    }
+
+    m_DefaultLifeTime = lifetime;
+       pLeash_set_default_lifetime(m_DefaultLifeTime);
+       m_initDefaultLifeTimeDay = m_newDefaultLifeTimeDay;
+       m_initDefaultLifeTimeHr  = m_newDefaultLifeTimeHr ;
+       m_initDefaultLifeTimeMin = m_newDefaultLifeTimeMin;
+
+    // If we're using an environment variable tell the user that we
+    // can't use Leash to modify the value.
+
+    if (!m_DefaultLifeTime)
+    {
+        MessageBox("A lifetime setting of 0 is special in that it means that "
+                   "the application is free to pick whatever default it deems "
+                   "appropriate",
+                   "Leash", MB_OK);
+    }
+
+       if ( m_initUseKrb4 != m_newUseKrb4 ) {
+               pLeash_set_default_use_krb4(m_newUseKrb4);
+       }
+
+       if ( m_initKinitPreserve != m_newKinitPreserve ) {
+               pLeash_set_default_preserve_kinit_settings(m_newKinitPreserve);
+       }
+
+       return TRUE;
+}
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultLifeTime()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+        GetDlgItemText(IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+        GetDlgItemText(IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+               DWORD value = (((atoi(m_newDefaultLifeTimeDay)*24 + atoi(m_newDefaultLifeTimeHr)) * 60) + atoi(m_newDefaultLifeTimeMin));
+               LPSTR buf = m_newDefaultLifeTimeDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeTimeDay.ReleaseBuffer();
+               buf = m_newDefaultLifeTimeHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeTimeHr.ReleaseBuffer();
+               buf = m_newDefaultLifeTimeMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeTimeMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+        SetDlgItemText(IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+        SetDlgItemText(IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+        SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultLifeTime()
+{
+    static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+        GetDlgItemText(IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+        GetDlgItemText(IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+               DWORD value = (((atoi(m_newDefaultLifeTimeDay)*24 + atoi(m_newDefaultLifeTimeHr)) * 60) + atoi(m_newDefaultLifeTimeMin));
+               LPSTR buf = m_newDefaultLifeTimeDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeTimeDay.ReleaseBuffer();
+               buf = m_newDefaultLifeTimeHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeTimeHr.ReleaseBuffer();
+               buf = m_newDefaultLifeTimeMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeTimeMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+        SetDlgItemText(IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+        SetDlgItemText(IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultLifeTimeEditBox()
+{
+    // Reset Config Tab's Default LifeTime Editbox
+
+       DWORD tmp = m_DefaultLifeTime = pLeash_get_default_lifetime();
+       LPSTR buf = m_newDefaultLifeTimeDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultLifeTimeDay.ReleaseBuffer();
+       buf = m_newDefaultLifeTimeHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultLifeTimeHr.ReleaseBuffer();
+       buf = m_newDefaultLifeTimeMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultLifeTimeMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+}
+
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultRenewTill()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+        GetDlgItemText(IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+        GetDlgItemText(IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+               DWORD value = (((atoi(m_newDefaultRenewTillDay)*24 + atoi(m_newDefaultRenewTillHr)) * 60) + atoi(m_newDefaultRenewTillMin));
+               LPSTR buf = m_newDefaultRenewTillDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewTillDay.ReleaseBuffer();
+               buf = m_newDefaultRenewTillHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewTillHr.ReleaseBuffer();
+               buf = m_newDefaultRenewTillMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewTillMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+        SetDlgItemText(IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+        SetDlgItemText(IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+        SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultRenewTill()
+{
+    static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+        GetDlgItemText(IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+        GetDlgItemText(IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+               DWORD value = (((atoi(m_newDefaultRenewTillDay)*24 + atoi(m_newDefaultRenewTillHr)) * 60) + atoi(m_newDefaultRenewTillMin));
+               LPSTR buf = m_newDefaultRenewTillDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewTillDay.ReleaseBuffer();
+               buf = m_newDefaultRenewTillHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewTillHr.ReleaseBuffer();
+               buf = m_newDefaultRenewTillMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewTillMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+        SetDlgItemText(IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+        SetDlgItemText(IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultRenewTillEditBox()
+{
+    // Reset Config Tab's Default RenewTill Editbox
+
+       DWORD tmp = m_DefaultRenewTill = pLeash_get_default_lifetime();
+       LPSTR buf = m_newDefaultRenewTillDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultRenewTillDay.ReleaseBuffer();
+       buf = m_newDefaultRenewTillHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultRenewTillHr.ReleaseBuffer();
+       buf = m_newDefaultRenewTillMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultRenewTillMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+}
+
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultLifeMin()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+               DWORD value = (((atoi(m_newDefaultLifeMinDay)*24 + atoi(m_newDefaultLifeMinHr)) * 60) + atoi(m_newDefaultLifeMinMin));
+               LPSTR buf = m_newDefaultLifeMinDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeMinDay.ReleaseBuffer();
+               buf = m_newDefaultLifeMinHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeMinHr.ReleaseBuffer();
+               buf = m_newDefaultLifeMinMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeMinMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+        SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultLifeMin()
+{
+    static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+        GetDlgItemText(IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+               DWORD value = (((atoi(m_newDefaultLifeMinDay)*24 + atoi(m_newDefaultLifeMinHr)) * 60) + atoi(m_newDefaultLifeMinMin));
+               LPSTR buf = m_newDefaultLifeMinDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeMinDay.ReleaseBuffer();
+               buf = m_newDefaultLifeMinHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeMinHr.ReleaseBuffer();
+               buf = m_newDefaultLifeMinMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeMinMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+        SetDlgItemText(IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+    }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultLifeMinEditBox()
+{
+    // Reset Config Tab's Default LifeMin Editbox
+
+       DWORD tmp = m_DefaultLifeMin = pLeash_get_default_life_min();
+       LPSTR buf = m_newDefaultLifeMinDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultLifeMinDay.ReleaseBuffer();
+       buf = m_newDefaultLifeMinHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultLifeMinHr.ReleaseBuffer();
+       buf = m_newDefaultLifeMinMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultLifeMinMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+}
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultLifeMax()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+               DWORD value = (((atoi(m_newDefaultLifeMaxDay)*24 + atoi(m_newDefaultLifeMaxHr)) * 60) + atoi(m_newDefaultLifeMaxMin));
+               LPSTR buf = m_newDefaultLifeMaxDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeMaxDay.ReleaseBuffer();
+               buf = m_newDefaultLifeMaxHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeMaxHr.ReleaseBuffer();
+               buf = m_newDefaultLifeMaxMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeMaxMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+
+        SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultLifeMax()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+        GetDlgItemText(IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+               DWORD value = (((atoi(m_newDefaultLifeMaxDay)*24 + atoi(m_newDefaultLifeMaxHr)) * 60) + atoi(m_newDefaultLifeMaxMin));
+               LPSTR buf = m_newDefaultLifeMaxDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultLifeMaxDay.ReleaseBuffer();
+               buf = m_newDefaultLifeMaxHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultLifeMaxHr.ReleaseBuffer();
+               buf = m_newDefaultLifeMaxMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultLifeMaxMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+        SetDlgItemText(IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultLifeMaxEditBox()
+{
+    // Reset Config Tab's Default LifeMax Editbox
+
+       DWORD tmp = m_DefaultLifeMax = pLeash_get_default_life_min();
+       LPSTR buf = m_newDefaultLifeMaxDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultLifeMaxDay.ReleaseBuffer();
+       buf = m_newDefaultLifeMaxHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultLifeMaxHr.ReleaseBuffer();
+       buf = m_newDefaultLifeMaxMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultLifeMaxMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+}
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultRenewMin()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+               DWORD value = (((atoi(m_newDefaultRenewMinDay)*24 + atoi(m_newDefaultRenewMinHr)) * 60) + atoi(m_newDefaultRenewMinMin));
+               LPSTR buf = m_newDefaultRenewMinDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewMinDay.ReleaseBuffer();
+               buf = m_newDefaultRenewMinHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewMinHr.ReleaseBuffer();
+               buf = m_newDefaultRenewMinMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewMinMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+
+        SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultRenewMin()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+        GetDlgItemText(IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+               DWORD value = (((atoi(m_newDefaultRenewMinDay)*24 + atoi(m_newDefaultRenewMinHr)) * 60) + atoi(m_newDefaultRenewMinMin));
+               LPSTR buf = m_newDefaultRenewMinDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewMinDay.ReleaseBuffer();
+               buf = m_newDefaultRenewMinHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewMinHr.ReleaseBuffer();
+               buf = m_newDefaultRenewMinMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewMinMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+        SetDlgItemText(IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultRenewMinEditBox()
+{
+    // Reset Config Tab's Default RenewMin Editbox
+
+       DWORD tmp = m_DefaultRenewMin = pLeash_get_default_life_min();
+       LPSTR buf = m_newDefaultRenewMinDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultRenewMinDay.ReleaseBuffer();
+       buf = m_newDefaultRenewMinHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultRenewMinHr.ReleaseBuffer();
+       buf = m_newDefaultRenewMinMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultRenewMinMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+}
+
+void CKrbMiscConfigOpt::OnSelchangeEditDefaultRenewMax()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+               DWORD value = (((atoi(m_newDefaultRenewMaxDay)*24 + atoi(m_newDefaultRenewMaxHr)) * 60) + atoi(m_newDefaultRenewMaxMin));
+               LPSTR buf = m_newDefaultRenewMaxDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewMaxDay.ReleaseBuffer();
+               buf = m_newDefaultRenewMaxHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewMaxHr.ReleaseBuffer();
+               buf = m_newDefaultRenewMaxMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewMaxMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+
+        SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::OnEditKillfocusEditDefaultRenewMax()
+{
+       static int in_progress = 0;
+    if (!in_progress && !m_startupPage2)
+    {
+               in_progress = 1;
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+        GetDlgItemText(IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+               DWORD value = (((atoi(m_newDefaultRenewMaxDay)*24 + atoi(m_newDefaultRenewMaxHr)) * 60) + atoi(m_newDefaultRenewMaxMin));
+               LPSTR buf = m_newDefaultRenewMaxDay.GetBuffer(80);
+               _itoa(value/24/60, buf, 10);
+               value %= (24 * 60);
+               m_newDefaultRenewMaxDay.ReleaseBuffer();
+               buf = m_newDefaultRenewMaxHr.GetBuffer(80);
+               _itoa(value/60, buf, 10);
+               value %= 60;
+               m_newDefaultRenewMaxHr.ReleaseBuffer();
+               buf = m_newDefaultRenewMaxMin.GetBuffer(80);
+               _itoa(value, buf, 10);
+               m_newDefaultRenewMaxMin.ReleaseBuffer();
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+        SetDlgItemText(IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+
+               SetModified(TRUE);
+               in_progress = 0;
+       }
+}
+
+void CKrbMiscConfigOpt::ResetDefaultRenewMaxEditBox()
+{
+    // Reset Config Tab's Default RenewMax Editbox
+
+       DWORD tmp = m_DefaultRenewMax = pLeash_get_default_life_min();
+       LPSTR buf = m_newDefaultRenewMaxDay.GetBuffer(80);
+       _itoa(tmp/24/60, buf, 10);
+       tmp %= (24 * 60);
+    m_newDefaultRenewMaxDay.ReleaseBuffer();
+       buf = m_newDefaultRenewMaxHr.GetBuffer(80);
+       _itoa(tmp/60, buf, 10);
+       tmp %= 60;
+    m_newDefaultRenewMaxHr.ReleaseBuffer();
+       buf = m_newDefaultRenewMaxMin.GetBuffer(80);
+       _itoa(tmp, buf, 10);
+    m_newDefaultRenewMaxMin.ReleaseBuffer();
+
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+       ::SetDlgItemText(::GetForegroundWindow(), IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+}
+
+void CKrbMiscConfigOpt::OnCheckUseKrb4()
+{
+    m_newUseKrb4 = (BOOL)IsDlgButtonChecked(IDC_CHECK_REQUEST_KRB4);
+}
+
+void CKrbMiscConfigOpt::OnCheckKinitPreserve()
+{
+    m_newKinitPreserve = (BOOL)IsDlgButtonChecked(IDC_CHECK_PRESERVE_KINIT_OPTIONS);
+}
+
+void CKrbMiscConfigOpt::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+    CPropertyPage::OnShowWindow(bShow, nStatus);
+
+    if (CLeashApp::m_hKrb5DLL)
+        ResetDefaultLifeTimeEditBox();
+
+       SetDlgItemText(IDC_EDIT_LIFETIME_D, m_newDefaultLifeTimeDay);
+       SetDlgItemText(IDC_EDIT_LIFETIME_H, m_newDefaultLifeTimeHr);
+       SetDlgItemText(IDC_EDIT_LIFETIME_M, m_newDefaultLifeTimeMin);
+       SetDlgItemText(IDC_EDIT_RENEWTILL_D, m_newDefaultRenewTillDay);
+       SetDlgItemText(IDC_EDIT_RENEWTILL_H, m_newDefaultRenewTillHr);
+       SetDlgItemText(IDC_EDIT_RENEWTILL_M, m_newDefaultRenewTillMin);
+       SetDlgItemText(IDC_EDIT_LIFE_MIN_D, m_newDefaultLifeMinDay);
+       SetDlgItemText(IDC_EDIT_LIFE_MIN_H, m_newDefaultLifeMinHr);
+       SetDlgItemText(IDC_EDIT_LIFE_MIN_M, m_newDefaultLifeMinMin);
+       SetDlgItemText(IDC_EDIT_LIFE_MAX_D, m_newDefaultLifeMaxDay);
+       SetDlgItemText(IDC_EDIT_LIFE_MAX_H, m_newDefaultLifeMaxHr);
+       SetDlgItemText(IDC_EDIT_LIFE_MAX_M, m_newDefaultLifeMaxMin);
+       SetDlgItemText(IDC_EDIT_RENEW_MIN_D, m_newDefaultRenewMinDay);
+       SetDlgItemText(IDC_EDIT_RENEW_MIN_H, m_newDefaultRenewMinHr);
+       SetDlgItemText(IDC_EDIT_RENEW_MIN_M, m_newDefaultRenewMinMin);
+       SetDlgItemText(IDC_EDIT_RENEW_MAX_D, m_newDefaultRenewMaxDay);
+       SetDlgItemText(IDC_EDIT_RENEW_MAX_H, m_newDefaultRenewMaxHr);
+       SetDlgItemText(IDC_EDIT_RENEW_MAX_M, m_newDefaultRenewMaxMin);
+}
+
+BOOL CKrbMiscConfigOpt::PreTranslateMessage(MSG* pMsg)
+{
+    if (!m_startupPage2)
+    {
+        if (m_noLifeTime)
+        {
+            MessageBox("A lifetime setting of 0 is special in that it means that "
+                       "the application is free to pick whatever default it deems "
+                       "appropriate",
+                       "Leash", MB_OK);
+            m_noLifeTime = FALSE;
+        }
+    }
+
+    m_startupPage2 = FALSE;
+    return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbMiscConfigOpt, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrbConfigOptions)
+       ON_WM_SHOWWINDOW()
+
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFETIME_D, OnEditKillfocusEditDefaultLifeTime)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFETIME_D, OnSelchangeEditDefaultLifeTime)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFETIME_H, OnEditKillfocusEditDefaultLifeTime)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFETIME_H, OnSelchangeEditDefaultLifeTime)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFETIME_M, OnEditKillfocusEditDefaultLifeTime)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFETIME_M, OnSelchangeEditDefaultLifeTime)
+
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEWTILL_D, OnEditKillfocusEditDefaultRenewTill)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEWTILL_D, OnSelchangeEditDefaultRenewTill)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEWTILL_H, OnEditKillfocusEditDefaultRenewTill)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEWTILL_H, OnSelchangeEditDefaultRenewTill)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEWTILL_M, OnEditKillfocusEditDefaultRenewTill)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEWTILL_M, OnSelchangeEditDefaultRenewTill)
+
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MIN_D, OnEditKillfocusEditDefaultLifeMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MIN_D, OnSelchangeEditDefaultLifeMin)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MIN_H, OnEditKillfocusEditDefaultLifeMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MIN_H, OnSelchangeEditDefaultLifeMin)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MIN_M, OnEditKillfocusEditDefaultLifeMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MIN_M, OnSelchangeEditDefaultLifeMin)
+
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MAX_D, OnEditKillfocusEditDefaultLifeMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MAX_D, OnSelchangeEditDefaultLifeMax)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MAX_H, OnEditKillfocusEditDefaultLifeMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MAX_H, OnSelchangeEditDefaultLifeMax)
+       ON_EN_KILLFOCUS(IDC_EDIT_LIFE_MAX_M, OnEditKillfocusEditDefaultLifeMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_LIFE_MAX_M, OnSelchangeEditDefaultLifeMax)
+
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MIN_D, OnEditKillfocusEditDefaultRenewMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MIN_D, OnSelchangeEditDefaultRenewMin)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MIN_H, OnEditKillfocusEditDefaultRenewMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MIN_H, OnSelchangeEditDefaultRenewMin)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MIN_M, OnEditKillfocusEditDefaultRenewMin)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MIN_M, OnSelchangeEditDefaultRenewMin)
+
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MAX_D, OnEditKillfocusEditDefaultRenewMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MAX_D, OnSelchangeEditDefaultRenewMax)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MAX_H, OnEditKillfocusEditDefaultRenewMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MAX_H, OnSelchangeEditDefaultRenewMax)
+       ON_EN_KILLFOCUS(IDC_EDIT_RENEW_MAX_M, OnEditKillfocusEditDefaultRenewMax)
+       ON_CBN_SELCHANGE(IDC_EDIT_RENEW_MAX_M, OnSelchangeEditDefaultRenewMax)
+
+    ON_BN_CLICKED(IDC_CHECK_REQUEST_KRB4, OnCheckUseKrb4)
+       ON_BN_CLICKED(IDC_CHECK_PRESERVE_KINIT_OPTIONS, OnCheckKinitPreserve)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
diff --git a/src/windows/leash/KrbMiscConfigOpt.h b/src/windows/leash/KrbMiscConfigOpt.h
new file mode 100644 (file)
index 0000000..e2daf29
--- /dev/null
@@ -0,0 +1,173 @@
+//*****************************************************************************
+// File:       KrbMiscConfigOpt.h
+// By:         Paul B. Hill
+// Created:    08/12/1999
+// Copyright:  @1999 Massachusetts Institute of Technology - All rights
+//             reserved.
+// Description: H file for KrbMiscConfigOpt.cpp.  Contains variables
+//             and functions for Kerberos Properties.
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 08/12/99    PBH     Original
+//*****************************************************************************
+
+
+#if !defined(AFX_MISCCONFIGOPT_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
+#define AFX_MISCONFIGOPT_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+
+#include "resource.h"
+
+
+///////////////////////////////////////////////////////////////////////
+// CKrbMiscConfigOptions dialog
+
+class CKrbMiscConfigOpt : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrbMiscConfigOpt)
+       BOOL m_startupPage2;
+    BOOL m_noLifeTime;
+
+       static UINT m_DefaultLifeTime;
+       static CString m_initDefaultLifeTimeMin;
+       static CString m_newDefaultLifeTimeMin;
+       static CString m_initDefaultLifeTimeHr;
+       static CString m_newDefaultLifeTimeHr;
+       static CString m_initDefaultLifeTimeDay;
+       static CString m_newDefaultLifeTimeDay;
+
+       static UINT m_DefaultRenewTill;
+       static CString m_initDefaultRenewTillMin;
+       static CString m_newDefaultRenewTillMin;
+       static CString m_initDefaultRenewTillHr;
+       static CString m_newDefaultRenewTillHr;
+       static CString m_initDefaultRenewTillDay;
+       static CString m_newDefaultRenewTillDay;
+
+       static UINT m_DefaultLifeMin;
+       static CString m_initDefaultLifeMinMin;
+       static CString m_newDefaultLifeMinMin;
+       static CString m_initDefaultLifeMinHr;
+       static CString m_newDefaultLifeMinHr;
+       static CString m_initDefaultLifeMinDay;
+       static CString m_newDefaultLifeMinDay;
+
+       static UINT m_DefaultLifeMax;
+       static CString m_initDefaultLifeMaxMin;
+       static CString m_newDefaultLifeMaxMin;
+       static CString m_initDefaultLifeMaxHr;
+       static CString m_newDefaultLifeMaxHr;
+       static CString m_initDefaultLifeMaxDay;
+       static CString m_newDefaultLifeMaxDay;
+
+       static UINT m_DefaultRenewMin;
+       static CString m_initDefaultRenewMinMin;
+       static CString m_newDefaultRenewMinMin;
+       static CString m_initDefaultRenewMinHr;
+       static CString m_newDefaultRenewMinHr;
+       static CString m_initDefaultRenewMinDay;
+       static CString m_newDefaultRenewMinDay;
+
+       static UINT m_DefaultRenewMax;
+       static CString m_initDefaultRenewMaxMin;
+       static CString m_newDefaultRenewMaxMin;
+       static CString m_initDefaultRenewMaxHr;
+       static CString m_newDefaultRenewMaxHr;
+       static CString m_initDefaultRenewMaxDay;
+       static CString m_newDefaultRenewMaxDay;
+
+       static void ResetDefaultLifeTimeEditBox();
+       static void ResetDefaultRenewTillEditBox();
+       static void ResetDefaultLifeMinEditBox();
+       static void ResetDefaultLifeMaxEditBox();
+       static void ResetDefaultRenewMinEditBox();
+       static void ResetDefaultRenewMaxEditBox();
+
+    BOOL m_initUseKrb4;
+    BOOL m_newUseKrb4;
+    BOOL m_initKinitPreserve;
+    BOOL m_newKinitPreserve;
+
+public:
+       CKrbMiscConfigOpt();
+       ~CKrbMiscConfigOpt();
+
+// Dialog Data
+       //{{AFX_DATA(CKrbMiscConfigOpt)
+       enum { IDD = IDD_KRB_PROP_MISC };
+       static CEdit m_krbLifeTimeDayEditbox;
+       static CEdit m_krbLifeTimeMinEditbox;
+       static CEdit m_krbLifeTimeHrEditbox;
+       static CEdit m_krbRenewTillDayEditbox;
+       static CEdit m_krbRenewTillMinEditbox;
+       static CEdit m_krbRenewTillHrEditbox;
+       static CEdit m_krbRenewMaxDayEditbox;
+       static CEdit m_krbRenewMinDayEditbox;
+       static CEdit m_krbLifeMinDayEditbox;
+       static CEdit m_krbLifeMinMinEditbox;
+       static CEdit m_krbLifeMinHrEditbox;
+       static CEdit m_krbLifeMaxDayEditbox;
+       static CEdit m_krbLifeMaxMinEditbox;
+       static CEdit m_krbLifeMaxHrEditbox;
+       static CEdit m_krbRenewMinMinEditbox;
+       static CEdit m_krbRenewMinHrEditbox;
+       static CEdit m_krbRenewMaxMinEditbox;
+       static CEdit m_krbRenewMaxHrEditbox;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generate virtual function overrides
+       //{{AFX_VIRTUAL(CKrbConfigOptions)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual VOID DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       virtual BOOL OnApply();
+
+// Implementation
+protected:
+       // Generated message map functions
+       //{{AFX_MSG(CKrbMiscConfigOpt)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnEditKillfocusEditDefaultLifeTime();
+       afx_msg void OnResetDefaultLifeTimeEditBox();
+       afx_msg void OnSelchangeEditDefaultLifeTime();
+       afx_msg void OnEditKillfocusEditDefaultRenewTill();
+       afx_msg void OnResetDefaultRenewTillEditBox();
+       afx_msg void OnSelchangeEditDefaultRenewTill();
+       afx_msg void OnEditKillfocusEditDefaultLifeMin();
+       afx_msg void OnResetDefaultLifeMinEditBox();
+       afx_msg void OnSelchangeEditDefaultLifeMin();
+       afx_msg void OnEditKillfocusEditDefaultLifeMax();
+       afx_msg void OnResetDefaultLifeMaxEditBox();
+       afx_msg void OnSelchangeEditDefaultLifeMax();
+       afx_msg void OnEditKillfocusEditDefaultRenewMin();
+       afx_msg void OnResetDefaultRenewMinEditBox();
+       afx_msg void OnSelchangeEditDefaultRenewMin();
+       afx_msg void OnEditKillfocusEditDefaultRenewMax();
+       afx_msg void OnResetDefaultRenewMaxEditBox();
+       afx_msg void OnSelchangeEditDefaultRenewMax();
+    afx_msg void OnCheckUseKrb4();
+    afx_msg void OnCheckKinitPreserve();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MISCONFIGOPT_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/KrbProperties.cpp b/src/windows/leash/KrbProperties.cpp
new file mode 100644 (file)
index 0000000..d26987e
--- /dev/null
@@ -0,0 +1,102 @@
+//     File:                   KrbProperties.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbProperties.h. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     02/01/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "KrbProperties.h"
+#include "Krb4Properties.h"
+
+#include "Leash.h"
+#include "wshelper.h"
+#include "lglobals.h"
+#include "reminder.h"
+
+CHAR CKrbProperties::m_krbPath[MAX_PATH];
+CHAR CKrbProperties::m_krbrealmPath[MAX_PATH];
+BOOL CKrbProperties::KrbPropertiesOn;
+
+///////////////////////////////////////////////////////////////////////
+// CKrbProperties
+
+IMPLEMENT_DYNAMIC(CKrbProperties, CPropertySheet)
+CKrbProperties::CKrbProperties(UINT nIDCaption, CWnd* pParentWnd,
+                               UINT iSelectPage)
+:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+{
+}
+
+CKrbProperties::CKrbProperties(LPCTSTR pszCaption, CWnd* pParentWnd,
+                                                          UINT iSelectPage)
+:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+{
+       KrbPropertiesOn = FALSE;
+
+#ifdef COMMENT
+       // If this will not be fatal, then it does not need to be performed here.
+       if (CLeashApp::m_hKrb5DLL)
+       {
+               char *realm = NULL;
+               pkrb5_get_default_realm(CLeashApp::m_krbv5_context, &realm);
+
+               if (!realm)
+               {
+                       MessageBox("CKrbProperties::Unable to determine default Kerberos REALM.\
+                        \n Consult your Administrator!",
+                                          "Error", MB_OK);
+                       // I don't think this is necessarily fatal.  - jaltman
+                       // return;
+               }
+       }
+#endif /* COMMENT */
+
+    CLeashApp::GetKrb4ConFile(m_krbPath,sizeof(m_krbPath));
+    CLeashApp::GetKrb4RealmFile(m_krbrealmPath,sizeof(m_krbrealmPath));
+
+
+       AddPage(&m_configOptions);
+       AddPage(&m_miscConfigOpt);
+
+       if (CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL)
+       {
+               AddPage(&m_krb4RealmHostMaintenance);
+               AddPage(&m_krb4DomainRealmMaintenance);
+       }
+       else if (CLeashApp::m_hKrb5DLL)
+       {
+               AddPage(&m_realmHostMaintenance);
+               AddPage(&m_domainRealmMaintenance);
+       }
+
+       KrbPropertiesOn = TRUE;
+}
+
+CKrbProperties::~CKrbProperties()
+{
+       KrbPropertiesOn = FALSE;
+}
+
+void CKrbProperties::OnHelp()
+{
+    AfxGetApp()->WinHelp(HID_KERBEROS_PROPERTIES_COMMAND);
+}
+
+
+BEGIN_MESSAGE_MAP(CKrbProperties, CPropertySheet)
+       //{{AFX_MSG_MAP(CKrbProperties)
+               // NOTE - the ClassWizard will add and remove mapping macros here.
+    ON_COMMAND(ID_HELP, OnHelp)
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+///////////////////////////////////////////////////////////////////////
+// CKrbProperties message handlers
diff --git a/src/windows/leash/KrbProperties.h b/src/windows/leash/KrbProperties.h
new file mode 100644 (file)
index 0000000..c73ca6e
--- /dev/null
@@ -0,0 +1,89 @@
+//     **************************************************************************************
+//     File:                   KrbProperties.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbProperties.cpp. Contains variables and functions
+//                                     for Kerberos Four Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     02/01/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_KRB_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
+#define AFX_KRB_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+// KrbProperties.h : header file
+//
+
+#include "KrbConfigOptions.h"
+#include "KrbRealmHostMaintenance.h"
+#include "KrbDomainRealmMaintenance.h"
+#include "Krb4DomainRealmMaintenance.h"
+#include "Krb4RealmHostMaintenance.h"
+#include "KrbMiscConfigOpt.h"
+
+//////////////////////////////////////////////////////////////////////
+// CKrbProperties
+
+class CKrbProperties : public CPropertySheet
+{
+private:
+       DECLARE_DYNAMIC(CKrbProperties)
+
+public:
+       //CKrbConfigFileLocation m_fileLocation;
+       CKrbConfigOptions m_configOptions;
+       CKrb4RealmHostMaintenance m_krb4RealmHostMaintenance;
+       CKrbRealmHostMaintenance m_realmHostMaintenance;
+       CKrb4DomainRealmMaintenance m_krb4DomainRealmMaintenance;
+       CKrbDomainRealmMaintenance m_domainRealmMaintenance;
+    CKrbMiscConfigOpt m_miscConfigOpt;
+
+       static BOOL KrbPropertiesOn;
+       static BOOL applyButtonEnabled;
+       static CHAR m_krbPath[MAX_PATH];
+       static CHAR m_krbrealmPath[MAX_PATH];
+
+// Construction
+public:
+       CKrbProperties(UINT nIDCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+       CKrbProperties(LPCTSTR pszCaption, CWnd* pParentWnd = NULL,
+                  UINT iSelectPage = 0);
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbProperties)
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CKrbProperties();
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CKrbProperties)
+               // NOTE - the ClassWizard will add and remove member functions here.
+    afx_msg void OnHelp();
+    //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRB_PROPERTY_H__CD702F99_7495_11D0_8FDC_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/KrbRealmHostMaintenance.cpp b/src/windows/leash/KrbRealmHostMaintenance.cpp
new file mode 100644 (file)
index 0000000..7dac506
--- /dev/null
@@ -0,0 +1,1047 @@
+//     **************************************************************************************
+//     File:                   KrbRealmHostMaintenance.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for KrbRealmHostMaintenance.h. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "KrbProperties.h"
+#include "Krb4Properties.h"
+#include "KrbAddRealm.h"
+#include "KrbAddHostServer.h"
+#include "KrbRealmHostMaintenance.h"
+#include "KrbEditRealm.h"
+#include "KrbEditHostServer.h"
+#include "KrbConfigOptions.h"
+
+#include "lglobals.h"
+#include "MainFrm.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbRealmHostMaintenance dialog
+
+
+IMPLEMENT_DYNCREATE(CKrbRealmHostMaintenance, CPropertyPage)
+
+CKrbRealmHostMaintenance::CKrbRealmHostMaintenance()
+ : CPropertyPage(CKrbRealmHostMaintenance::IDD)
+{
+       m_isRealmListBoxInFocus = FALSE;
+       m_isStart = TRUE;
+       m_theAdminServer = _T("");
+       m_theAdminServerMarked = _T("");
+    m_initDnsKdcLookup = 0;
+    m_newDnsKdcLookup = 0;
+
+       m_KDCHostList.initOtherListbox(this, &m_KDCRealmList);
+}
+
+CKrbRealmHostMaintenance::~CKrbRealmHostMaintenance()
+{
+}
+
+void CKrbRealmHostMaintenance::DoDataExchange(CDataExchange* pDX)
+{
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CKrbRealmHostMaintenance)
+       DDX_Control(pDX, IDC_LIST_KDC_REALM, m_KDCRealmList);
+       DDX_Control(pDX, IDC_LIST_KDC_HOST, m_KDCHostList);
+       //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CKrbRealmHostMaintenance, CPropertyPage)
+       //{{AFX_MSG_MAP(CKrbRealmHostMaintenance)
+       ON_BN_CLICKED(IDC_BUTTON_REALM_HOST_ADD, OnButtonRealmHostAdd)
+       ON_BN_CLICKED(IDC_BUTTON_REALM_EDIT, OnButtonRealmHostEdit)
+       ON_BN_CLICKED(ID_BUTTON_REALM_REMOVE, OnButtonRealmHostRemove)
+       ON_LBN_SELCHANGE(IDC_LIST_KDC_REALM, OnSelchangeListKdcRealm)
+       ON_BN_CLICKED(IDC_BUTTON_ADMINSERVER, OnButtonAdminserver)
+       ON_LBN_SETFOCUS(IDC_LIST_KDC_REALM, OnSetfocusListKdcRealm)
+       ON_BN_CLICKED(IDC_BUTTON_KDCHOST_ADD, OnButtonKdchostAdd)
+       ON_BN_CLICKED(IDC_BUTTON_KDCHOST_REMOVE, OnButtonKdchostRemove)
+       ON_BN_CLICKED(IDC_BUTTON_REMOVE_ADMINSERVER, OnButtonRemoveAdminserver)
+       ON_LBN_SELCHANGE(IDC_LIST_KDC_HOST, OnSelchangeListKdcHost)
+       ON_BN_CLICKED(IDC_BUTTON_KDCHOST_EDIT, OnButtonKdchostEdit)
+       ON_LBN_DBLCLK(IDC_LIST_KDC_REALM, OnDblclkListKdcRealm)
+       ON_LBN_DBLCLK(IDC_LIST_KDC_HOST, OnDblclkListKdcHost)
+       ON_WM_KEYDOWN()
+       ON_WM_CANCELMODE()
+       ON_BN_CLICKED(IDC_BUTTON_REALMHOST_MAINT_HELP, OnButtonRealmhostMaintHelp)
+    ON_BN_CLICKED(IDC_DNS_KDC, OnCheckDnsKdcLookup)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbRealmHostMaintenance message handlers
+
+BOOL CKrbRealmHostMaintenance::OnInitDialog()
+{
+       CPropertyPage::OnInitDialog();
+
+       const char*  rootSection[] = {"realms", NULL};
+       const char** rootsec = rootSection;
+       char **sections = NULL,
+                **cpp = NULL,
+          *value = NULL;
+
+       long retval = pprofile_get_subsection_names(CLeashApp::m_krbv5_profile,
+                                                   rootsec, &sections);
+
+       if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnInitDialog::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return TRUE;
+       }
+
+       for (cpp = sections; *cpp; cpp++)
+       {
+               if (LB_ERR == m_KDCRealmList.AddString(*cpp))
+               {
+                       MessageBox("OnInitDialog::Can't add to Kerberos Realm Listbox",
+                                               "Leash", MB_OK);
+                       return FALSE;
+               }
+       }
+
+       pprofile_free_list(sections);
+
+    // Determine the starting value for DNS KDC Lookup Checkbox
+    retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                               "dns_lookup_kdc", 0, 0, &value);
+    if (value == 0 && retval == 0)
+        retval = pprofile_get_string(CLeashApp::m_krbv5_profile, "libdefaults",
+                                  "dns_fallback", 0, 0, &value);
+    if (value == 0) {
+#if KRB5_DNS_LOOKUP_KDC
+        m_initDnsKdcLookup = m_newDnsKdcLookup = 1;
+#else
+        m_initDnsKdcLookup = m_newDnsKdcLookup = 0;
+#endif
+    } else {
+        m_initDnsKdcLookup = m_newDnsKdcLookup = config_boolean_to_int(value);
+        pprofile_release_string(value);
+    }
+    CheckDlgButton(IDC_DNS_KDC, m_initDnsKdcLookup);
+
+    // Compaire Krb Four with what's in the Krb Five Profile Linklist
+       // and add to m_KDCRealmList if needed.
+       m_KDCRealmList.SetCurSel(0);
+
+       if (!m_KDCRealmList.GetCount())
+       {
+               GetDlgItem(IDC_BUTTON_REALM_EDIT)->EnableWindow(FALSE);
+       }
+       else if (1 >= m_KDCRealmList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow(FALSE);
+       }
+       else
+       {
+               GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow();
+               GetDlgItem(IDC_BUTTON_REALM_EDIT)->EnableWindow();
+       }
+
+
+       if (!m_KDCHostList.GetCount())
+       {
+               GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow(FALSE);
+       }
+       else
+       {
+               GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow();
+               GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow();
+       }
+
+
+       return TRUE;
+}
+
+BOOL CKrbRealmHostMaintenance::OnApply()
+{
+    char theSection[REALM_SZ + 1];
+    const char*  adminServer[] = {"realms", theSection, ADMIN_SERVER, NULL};
+    const char*  Section[] = {"realms", theSection, "kdc", NULL}; //theSection
+    const char** section = Section;
+    const char** adminServ = adminServer;
+
+    if (!CLeashApp::m_krbv5_profile) {
+        CHAR confname[MAX_PATH];
+        if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+        {
+               const char *filenames[2];
+                   filenames[0] = confname;
+                       filenames[1] = NULL;
+                       pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+               }
+       }
+
+       /*
+    // Safety check for empty section (may not be need, but left it in anyway)
+       INT maxRealms = m_KDCRealmList.GetCount();
+       for (INT realm = 0; realm < maxRealms; realm++)
+       {
+               m_KDCRealmList.GetText(realm, theSection);
+               long retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                                      section, &values);
+        pprofile_free_list(values);
+
+        if (PROF_NO_RELATION == retval)
+               {
+                       if (IDYES == AfxMessageBox("One or more Realms do not have any corresponing Servers!!!\n\nContinue?",
+                               MB_YESNO))
+                         break;
+                       else
+                         return TRUE;
+               }
+
+               if (retval && PROF_NO_RELATION != retval)
+               {
+                       MessageBox("OnApply::There is an error, profile will not be saved!!!\nIf this error persist, contact your administrator.",
+                                      "Error", MB_OK);
+                       return TRUE;
+               }
+    }
+    */
+
+    long retval = pprofile_flush(CLeashApp::m_krbv5_profile);
+
+    if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnApply::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+       }
+
+
+    // Save to Kerberos Four config. file "Krb.con"
+    CStdioFile krbCon;
+       if (!krbCon.Open(CKrbProperties::m_krbPath, CFile::modeCreate |
+                                                                                           CFile::modeNoTruncate |
+                                                                                               CFile::modeReadWrite))
+       {
+               LeashErrorBox("OnApply::Can't open Configuration File",
+                                         CKrbProperties::m_krbPath);
+               return TRUE;
+       }
+
+       krbCon.SetLength(0);
+
+       krbCon.WriteString(CKrbConfigOptions::m_newDefaultRealm);
+       krbCon.WriteString("\n");
+
+       for (INT maxItems = m_KDCRealmList.GetCount(), item = 0; item < maxItems; item++)
+       {
+        char **values = NULL,
+                **cpp = NULL,
+                **admin = NULL;
+
+        if (LB_ERR == m_KDCRealmList.GetText(item, theSection))
+                 ASSERT(0);
+
+        retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                                                         section, &values);
+
+        if (retval && PROF_NO_RELATION != retval)
+               {
+                       MessageBox("OnApply::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                      "Leash", MB_OK);
+               }
+
+           retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                                                         adminServ , &admin);
+
+               if (retval && PROF_NO_RELATION != retval)
+               {
+                       MessageBox("OnApply::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                      "Leash", MB_OK);
+               }
+
+        char* pSemiCl = NULL;
+               if (admin)
+        {
+            if (*admin)
+            {
+                if ((pSemiCl = strchr(*admin, ':')))
+                     *pSemiCl = 0;
+            }
+        }
+
+
+        char hostKdc[MAX_HSTNM];
+               if (values)
+        for (cpp = values; *cpp; cpp++)
+               {
+                       strcpy(hostKdc, *cpp);
+
+            if ((pSemiCl = strchr(hostKdc, ':')))
+                     *pSemiCl = 0;
+
+            if (admin)
+            {
+                if (*admin)
+                {
+                    if (0 == stricmp(hostKdc, *admin))
+                      strcat(hostKdc, " admin server");
+                }
+            }
+
+            CString kdcHost = theSection;
+                       kdcHost += " ";
+                       kdcHost += hostKdc;
+
+                       krbCon.WriteString(kdcHost);
+                       krbCon.WriteString("\n");
+               }
+
+       if (values)
+          pprofile_free_list(values);
+
+        if (admin)
+          pprofile_free_list(admin);
+    }
+
+    if ( m_newDnsKdcLookup )
+        krbCon.WriteString(".KERBEROS.OPTION. dns\n");
+
+    krbCon. Close();
+    return TRUE;
+}
+
+void CKrbRealmHostMaintenance::OnCancel()
+{
+    CHAR fileName[MAX_PATH];
+    if (CLeashApp::GetProfileFile(fileName, sizeof(fileName)))
+    {
+        MessageBox("Can't locate Kerberos Five Config. file!", "Error", MB_OK);
+        return;
+    }
+
+
+    long retval = 0;
+    if (CLeashApp::m_krbv5_profile)
+        pprofile_abandon(CLeashApp::m_krbv5_profile);
+
+    /*
+    if (retval)
+       {
+               MessageBox("OnButtonRealmHostAdd::There is an error, profile will not be abandon!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+       */
+
+    const char *filenames[2];
+    filenames[0] = fileName;
+    filenames[1] = NULL;
+       retval = pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+
+    if (retval)
+       {
+               MessageBox("OnButtonRealmHostAdd::There is an error, profile will not be initialized!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+
+       CPropertyPage::OnCancel();
+}
+
+void CKrbRealmHostMaintenance::OnCheckDnsKdcLookup()
+{
+       const char*  dnsLookupKdc[] = {"libdefaults","dns_lookup_kdc",NULL};
+
+    m_newDnsKdcLookup = (BOOL)IsDlgButtonChecked(IDC_DNS_KDC);
+
+       long retval = pprofile_clear_relation(CLeashApp::m_krbv5_profile,
+                                                                                 dnsLookupKdc);
+
+    if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnButtonAdminserver::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+
+       retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                    dnsLookupKdc,
+                                    m_newDnsKdcLookup ? "true" : "false");
+
+       if (retval)
+       { // this might not be a good way to handle this type of error
+               MessageBox("OnButtonAdminserver::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+    SetModified(TRUE);
+}
+
+void CKrbRealmHostMaintenance::OnButtonRealmHostAdd()
+{
+    m_KDCRealmList.SetFocus();
+
+    CKrbAddRealm addToRealmHostList;
+       if (IDOK == addToRealmHostList.DoModal())
+       {
+               char theSection[REALM_SZ + 1];
+               const char* Section[] = {"realms", theSection, NULL};
+               const char** section = Section;
+
+
+           if (!CLeashApp::m_krbv5_profile) {
+               CHAR confname[MAX_PATH];
+               if (!CLeashApp::GetProfileFile(confname, sizeof(confname)))
+               {
+                   const char *filenames[2];
+                   filenames[0] = confname;
+                   filenames[1] = NULL;
+                   pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+               }
+           }
+
+               CString newRealm; // new section in the profile linklist
+               newRealm = addToRealmHostList.GetNewRealm();
+
+               if (LB_ERR != m_KDCRealmList.FindStringExact(-1, newRealm))
+               {
+                       MessageBox("We can't have duplicate Realms!\nYour entry was not saved to list.",
+                       "Leash", MB_OK);
+                       return;
+               }
+
+               if (addToRealmHostList.GetNewRealm().IsEmpty())
+                 ASSERT(0);
+
+               strcpy(theSection, newRealm);
+               long retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                    section, NULL);
+
+               if (retval)
+               {
+                       MessageBox("OnButtonRealmHostAdd::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                      "Leash", MB_OK);
+                       return;
+               }
+
+               if (LB_ERR == m_KDCRealmList.AddString(newRealm))
+                 ASSERT(0);
+
+               if (LB_ERR == m_KDCRealmList.SetCurSel(m_KDCRealmList.FindStringExact(-1, newRealm)))
+                 ASSERT(0);
+
+               MessageBox("You must now add a Kerberos Host Server or Realm you just added will be removed!!!",
+                                  "Leash", MB_OK);
+
+               m_KDCHostList.ResetContent();
+        if (OnButtonKdchostAddInternal())
+               { // Cancel
+
+                       long retval = pprofile_rename_section(CLeashApp::m_krbv5_profile,
+                                                                                                  section, NULL);
+
+                       if (retval)
+                       {
+                               MessageBox("OnButtonRealmHostRemove::There is an error, profile will not be saved!!!\
+                            \nIf this error persist, contact your administrator.",
+                                                  "Leash", MB_OK);
+                               return;
+                       }
+
+                       if (LB_ERR == m_KDCRealmList.DeleteString(m_KDCRealmList.GetCurSel()))
+                         ASSERT(0);
+
+                       m_KDCRealmList.SetCurSel(0);
+               }
+
+               OnSelchangeListKdcRealm();
+               SetModified(TRUE);
+       }
+
+       if (1 >= m_KDCRealmList.GetCount())
+       {
+               GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow(FALSE);
+       }
+       else
+       {
+               GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow();
+               GetDlgItem(IDC_BUTTON_REALM_EDIT)->EnableWindow();
+       }
+}
+
+void CKrbRealmHostMaintenance::OnButtonKdchostAdd()
+{
+    OnButtonKdchostAddInternal();
+}
+
+bool CKrbRealmHostMaintenance::OnButtonKdchostAddInternal()
+{
+       CString newHost; // new section in the profile linklist
+    CKrbAddHostServer addHostServer;
+       if (IDOK == addHostServer.DoModal())
+       { // OK
+               char theSection[MAX_HSTNM + 1];
+               const char* Section[] = {"realms", theSection, "kdc", NULL};
+               const char** section = Section;
+
+               if (addHostServer.GetNewHost().IsEmpty())
+                 ASSERT(0);
+
+               newHost = addHostServer.GetNewHost();
+
+               if (LB_ERR != m_KDCHostList.FindStringExact(-1, newHost))
+               {
+                       MessageBox("We can't have duplicate Host Servers for the same Realm!\
+                        \nYour entry was not saved to list.",
+                       "Leash", MB_OK);
+                       return true;
+               }
+
+               m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+           long retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                                                section, addHostServer.GetNewHost());
+
+               if (retval)
+               {
+                       MessageBox("OnButtonKdchostAdd::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+
+                       return true;
+               }
+
+        if (LB_ERR == m_KDCHostList.AddString(newHost))
+                 ASSERT(0);
+
+               SetModified(TRUE);
+       }
+       else
+         return true;
+
+       if (m_KDCHostList.GetCount() > 1)
+    {
+        m_KDCHostList.SetCurSel(m_KDCHostList.FindStringExact(-1, newHost));
+           m_KDCHostList.SetFocus();
+        OnSelchangeListKdcHost();
+
+        GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow();
+    }
+
+    if (1 == m_KDCRealmList.GetCount())
+       {
+        GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow();
+               GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow();
+       }
+
+       return false;
+}
+
+void CKrbRealmHostMaintenance::OnButtonRealmHostEdit()
+{
+       INT selItemIndex = m_KDCRealmList.GetCurSel();
+       CString selItem;
+
+    m_KDCHostList.SetFocus();
+    //m_KDCRealmList.SetFocus();
+    //m_KDCHostList.SetCurSel(0);
+    m_KDCRealmList.GetText(selItemIndex, selItem);
+
+       CKrbEditRealm editRealmHostList(selItem);
+
+       if (IDOK == editRealmHostList.DoModal())
+       {
+               char theSection[REALM_SZ + 1];
+               const char* Section[] = {"realms", theSection, NULL};
+               const char** section = Section;
+
+               CString editedRealm = editRealmHostList.GetEditedItem();
+
+               if (0 != editedRealm.CompareNoCase(selItem) &&
+                       LB_ERR != m_KDCRealmList.FindStringExact(-1, editedRealm))
+               {
+                       MessageBox("We can't have duplicate Realms!\nYour entry was not saved to list.",
+                       "Leash", MB_OK);
+                       return;
+               }
+
+               strcpy(theSection, selItem);
+
+               long retval = pprofile_rename_section(CLeashApp::m_krbv5_profile,
+                                                                                          section, editRealmHostList.GetEditedItem());
+
+               if (retval)
+               {
+                       MessageBox("OnButtonRealmHostEdit::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               m_KDCRealmList.DeleteString(selItemIndex);
+               m_KDCRealmList.AddString(editedRealm);
+               selItemIndex = m_KDCRealmList.FindStringExact(-1, editedRealm);
+               m_KDCRealmList.SetCurSel(selItemIndex);
+
+               CKrbConfigOptions::ResetDefaultRealmComboBox();
+               SetModified(TRUE);
+       }
+}
+
+void CKrbRealmHostMaintenance::OnDblclkListKdcRealm()
+{
+       OnButtonRealmHostEdit();
+}
+
+void CKrbRealmHostMaintenance::OnButtonKdchostEdit()
+{
+       INT selItemIndex = m_KDCHostList.GetCurSel();
+       CHAR OLD_VALUE[MAX_HSTNM + 1];
+       CString editedHostServer;
+       CString _adminServer;
+
+    m_KDCHostList.SetFocus();
+    m_KDCHostList.GetText(selItemIndex, OLD_VALUE);
+
+       LPSTR pOLD_VALUE = strchr(OLD_VALUE, ' ');
+       if (pOLD_VALUE)
+       {
+               *pOLD_VALUE = 0;
+               _adminServer = pOLD_VALUE + 1;
+       }
+
+       CString selItem = OLD_VALUE;
+       CKrbEditHostServer editHostServerList(selItem);
+
+       if (IDOK == editHostServerList.DoModal())
+       {
+               char theSection[REALM_SZ + 1];
+               const char*  adminServer[] = {"realms", theSection, ADMIN_SERVER, NULL};
+               const char* Section[] = {"realms", theSection, "kdc", NULL};
+               const char** section = Section;
+               const char** adminServ = adminServer;
+
+               editedHostServer = editHostServerList.GetEditedItem();
+
+               if (0 != editedHostServer.CompareNoCase(selItem) &&
+                       LB_ERR != m_KDCHostList.FindStringExact(-1, editedHostServer))
+               {
+                       MessageBox("We can't have duplicate Host Servers for the same Realm!\
+                        \nYour entry was not saved to list.",
+                       "Leash", MB_OK);
+                       return;
+               }
+
+               m_KDCHostList.DeleteString(selItemIndex);
+               m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+
+               if (!_adminServer.IsEmpty())
+               { // there is a admin_server
+                       editedHostServer += " ";
+                       editedHostServer += _adminServer;
+
+                       long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                                                        adminServ, OLD_VALUE,  editHostServerList.GetEditedItem());
+                       if (retval)
+                       {
+                               MessageBox("OnButtonKdchostEdit::There is an error, profile will not be saved!!!\
+                            \nIf this error persist, contact your administrator.",
+                                                  "Leash", MB_OK);
+                               return;
+                       }
+               }
+
+               long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                               section, OLD_VALUE,     editHostServerList.GetEditedItem());
+
+               if (retval)
+               {
+                       MessageBox("OnButtonKdchostEdit::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Leash", MB_OK);
+                       return;
+               }
+
+               m_KDCHostList.InsertString(selItemIndex, editedHostServer);
+               m_KDCHostList.SetCurSel(selItemIndex);
+
+               OnSelchangeListKdcHost();
+               SetModified(TRUE);
+       }
+}
+
+void CKrbRealmHostMaintenance::OnDblclkListKdcHost()
+{
+       OnButtonKdchostEdit();
+}
+
+void CKrbRealmHostMaintenance::OnButtonRealmHostRemove()
+{
+       char theSection[REALM_SZ + 1];
+       const char* Section[] = {"realms", theSection, NULL};
+       const char** section = Section;
+
+    m_KDCRealmList.SetFocus();
+    m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+
+       CString RealmMsg;
+       RealmMsg.Format("Your about to remove a Realm, \"%s\", and all it's dependents from the list!\n\nContinue?",
+                                       theSection);
+
+       if (IDYES != AfxMessageBox(RealmMsg, MB_YESNO))
+         return;
+
+       long retval = pprofile_rename_section(CLeashApp::m_krbv5_profile,
+                                                                                  section, NULL);
+
+       if (retval)
+       {
+               MessageBox("OnButtonRealmHostRemove::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+       INT curSel = m_KDCRealmList.GetCurSel();
+
+       if (LB_ERR == m_KDCRealmList.DeleteString(curSel))
+         ASSERT(0);// Single Sel Listbox
+
+       if (-1 == m_KDCRealmList.SetCurSel(curSel))
+         m_KDCRealmList.SetCurSel(curSel - 1);
+
+       SetModified(TRUE);
+
+       if (!m_KDCRealmList.GetCount())
+       {
+               GetDlgItem(IDC_BUTTON_REALM_EDIT)->EnableWindow(FALSE);
+       }
+       if (1 >= m_KDCRealmList.GetCount())
+       {
+               OnSelchangeListKdcRealm();
+               GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow(FALSE);
+       }
+       else
+         OnSelchangeListKdcRealm();
+}
+
+void CKrbRealmHostMaintenance::OnButtonKdchostRemove()
+{
+       char theSection[REALM_SZ + 1];
+       const char*  adminServer[] = {"realms", theSection, ADMIN_SERVER, NULL};
+       const char* Section[] = {"realms", theSection, "kdc", NULL};
+       const char** section = Section;
+       const char** adminServ = adminServer;
+       CHAR OLD_VALUE[MAX_HSTNM + 1];
+       CString serverHostMsg;
+       CString serverHost;
+       CString _adminServer;
+
+    m_KDCHostList.GetText(m_KDCHostList.GetCurSel(), serverHost);
+       serverHostMsg.Format("Your about to remove Server \"%s\" from the list!\n\nContinue?",
+                                                 serverHost);
+
+       if (IDYES != AfxMessageBox(serverHostMsg, MB_YESNO))
+         return;
+
+       m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+       INT curSel = m_KDCHostList.GetCurSel();
+       m_KDCHostList.GetText(curSel, OLD_VALUE);
+
+       LPSTR pOLD_VALUE = strchr(OLD_VALUE, ' ');
+       if (pOLD_VALUE)
+       {
+               *pOLD_VALUE = 0;
+               _adminServer = pOLD_VALUE + 1;
+       }
+
+       long retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                                   section, OLD_VALUE, NULL);
+       if (retval)
+       {
+               MessageBox("OnButtonKdchostRemove::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Leash", MB_OK);
+               return;
+       }
+
+       if (!_adminServer.IsEmpty())
+       { // there is a admin_server
+               retval = pprofile_update_relation(CLeashApp::m_krbv5_profile,
+                                                                                  adminServ, OLD_VALUE, NULL);
+               if (retval)
+               {
+                       MessageBox("OnButtonKdchostRemove::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                                          "Error", MB_OK);
+                       return;
+               }
+       }
+
+       m_KDCHostList.DeleteString(curSel);
+
+       if (-1 == m_KDCHostList.SetCurSel(curSel))
+         m_KDCHostList.SetCurSel(curSel - 1);
+
+       SetModified(TRUE);
+
+       if (!m_KDCHostList.GetCount())
+       {
+               GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow(FALSE);
+       }
+       else if (m_KDCHostList.GetCount() <= 1)
+         GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow(FALSE);
+
+    OnSelchangeListKdcHost();
+}
+
+BOOL CKrbRealmHostMaintenance::PreTranslateMessage(MSG* pMsg)
+{
+       if (m_isStart)
+       {
+               OnSelchangeListKdcRealm();
+               m_isStart = FALSE;
+       }
+
+       return CPropertyPage::PreTranslateMessage(pMsg);
+}
+
+void CKrbRealmHostMaintenance::OnSelchangeListKdcRealm()
+{
+       char theSection[REALM_SZ + 1];
+       const char*  adminServer[] = {"realms", theSection, ADMIN_SERVER, NULL};
+       const char*  Section[] = {"realms", theSection, "kdc", NULL}; //theSection
+       const char** section = Section;
+       const char** adminServ = adminServer;
+       char **values = NULL,
+                **adminValue = NULL,
+                **cpp = NULL;
+
+       m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+
+       long retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                          section, &values);
+
+       if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnSelchangeListKdcRealm::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+
+       m_KDCHostList.ResetContent();
+
+    if ( !retval && values ) {
+        retval = pprofile_get_values(CLeashApp::m_krbv5_profile,
+                                      adminServ, &adminValue);
+
+        if (retval && PROF_NO_RELATION != retval)
+        {
+            MessageBox("OnSelchangeListKdcRealm::There is an error, profile will not be saved!!!\
+                        \nIf this error persist, contact your administrator.",
+                        "Error", MB_OK);
+            return;
+        }
+
+        m_theAdminServer = _T("");
+        m_theAdminServerMarked = _T("");
+
+        for (cpp = values; *cpp; cpp++)
+        {
+            CString kdcHost = *cpp;
+
+            if (adminValue && 0 == strcmp(*adminValue, *cpp))
+            {
+                m_theAdminServer = kdcHost;
+                kdcHost += " ";
+                kdcHost += ADMIN_SERVER;
+
+                m_theAdminServerMarked = kdcHost;
+            }
+
+            if (LB_ERR == m_KDCHostList.AddString(kdcHost))
+            {
+                MessageBox("OnSelchangeListKdcRealm::Can't add Realm to Listbox",
+                            "Error", MB_OK);
+            }
+        }
+
+        pprofile_free_list(values);
+    } else {
+        GetDlgItem(IDC_BUTTON_REALM_HOST_ADD)->EnableWindow(TRUE);
+        GetDlgItem(ID_BUTTON_REALM_REMOVE)->EnableWindow(FALSE);
+        GetDlgItem(IDC_BUTTON_REALM_EDIT)->EnableWindow(FALSE);
+    }
+    CKrbConfigOptions::ResetDefaultRealmComboBox();
+
+       GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow(FALSE);
+       GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow(FALSE);
+}
+
+void CKrbRealmHostMaintenance::OnSelchangeListKdcHost()
+{
+       CString adminServer;
+       m_KDCHostList.GetText(m_KDCHostList.GetCurSel(), adminServer);
+
+       if (-1 != adminServer.Find(ADMIN_SERVER))
+       {
+               GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow(FALSE);
+               GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow();
+       }
+       else
+       {
+               GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow();
+               GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow(FALSE);
+       }
+
+       if (m_KDCHostList.GetCount() > 1)
+         GetDlgItem(IDC_BUTTON_KDCHOST_REMOVE)->EnableWindow();
+
+       GetDlgItem(IDC_BUTTON_KDCHOST_EDIT)->EnableWindow();
+}
+
+void CKrbRealmHostMaintenance::OnSetfocusListKdcRealm()
+{
+       GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow(FALSE);
+       GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow(FALSE);
+}
+
+void CKrbRealmHostMaintenance::OnButtonAdminserver()
+{
+       // Install new admin.server in profile linklist
+       char theSection[REALM_SZ + 1];
+       const char* Section[] = {"realms", theSection, ADMIN_SERVER, NULL};
+       const char** section = Section;
+
+    m_KDCHostList.SetFocus();
+    INT index1 = m_KDCHostList.GetCurSel();
+       INT index2 = m_KDCHostList.FindStringExact(-1, m_theAdminServerMarked);
+
+       if (-1 != index2)
+       {
+               m_KDCHostList.DeleteString(index2);
+               if (LB_ERR == m_KDCHostList.InsertString(index2, m_theAdminServer))
+               {
+                       MessageBox("OnButtonAdminserver::Can't add to list!!!",
+                                                 "Error, MB_OK");
+               }
+       }
+
+       CString makeAdmin;
+       m_KDCHostList.GetText(index1, makeAdmin);
+       m_KDCHostList.DeleteString(index1);
+       m_theAdminServer = makeAdmin;
+       makeAdmin += " ";
+       makeAdmin += ADMIN_SERVER;
+       m_theAdminServerMarked = makeAdmin;
+
+       if (LB_ERR == m_KDCHostList.InsertString(index1, makeAdmin))
+       {
+               MessageBox("OnButtonAdminserver::Can't add to list!!!",
+                                         "Error, MB_OK");
+       }
+
+       m_KDCHostList.SetCurSel(m_KDCHostList.FindStringExact(-1, makeAdmin)); //index2 -1);
+       GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow(FALSE);
+       GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow();
+
+       m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+
+       long retval = pprofile_clear_relation(CLeashApp::m_krbv5_profile,
+                                                                                  section);
+
+    if (retval && PROF_NO_RELATION != retval)
+       {
+               MessageBox("OnButtonAdminserver::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+
+       retval = pprofile_add_relation(CLeashApp::m_krbv5_profile,
+                                                       section, m_theAdminServer);
+
+       if (retval)
+       { // this might not be a good way to handle this type of error
+               MessageBox("OnButtonAdminserver::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+
+       SetModified(TRUE);
+}
+
+void CKrbRealmHostMaintenance::OnButtonRemoveAdminserver()
+{
+       // Remove admin.server from profile linklist
+       char theSection[REALM_SZ + 1];
+       const char* Section[] = {"realms", theSection, ADMIN_SERVER, NULL};
+       const char** section = Section;
+
+    m_KDCHostList.SetFocus();
+    m_KDCRealmList.GetText(m_KDCRealmList.GetCurSel(), theSection);
+
+       long retval = pprofile_clear_relation(CLeashApp::m_krbv5_profile,
+                                                                                  section);
+
+       if (retval)
+       {
+               MessageBox("OnButtonRemoveAdminserver::There is an error, profile will not be saved!!!\
+                    \nIf this error persist, contact your administrator.",
+                                  "Error", MB_OK);
+               return;
+       }
+
+    INT index = m_KDCHostList.GetCurSel();
+       m_KDCHostList.DeleteString(index);
+
+    if (LB_ERR == m_KDCHostList.InsertString(index, m_theAdminServer))
+       {
+               MessageBox("OnButtonRemoveAdminserver::Can't add to list!!!",
+                                         "Error, MB_OK");
+
+
+       }
+
+       m_theAdminServerMarked = m_theAdminServer;
+       m_KDCHostList.SetCurSel(m_KDCHostList.FindStringExact(-1, m_theAdminServer));
+       GetDlgItem(IDC_BUTTON_ADMINSERVER)->EnableWindow();
+       GetDlgItem(IDC_BUTTON_REMOVE_ADMINSERVER)->EnableWindow(FALSE);
+
+       SetModified(TRUE);
+}
+
+
+
+void CKrbRealmHostMaintenance::OnButtonRealmhostMaintHelp()
+{
+       MessageBox("No Help Available!", "Note", MB_OK);
+}
diff --git a/src/windows/leash/KrbRealmHostMaintenance.h b/src/windows/leash/KrbRealmHostMaintenance.h
new file mode 100644 (file)
index 0000000..c894e22
--- /dev/null
@@ -0,0 +1,102 @@
+//     **************************************************************************************
+//     File:                   KrbRealmHostMaintenance.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for KrbRealmHostMaintenance.cpp. Contains variables and functions
+//                                     for Kerberos Four and Five Properties
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_KRBREALMNAMEMAINTENANCE_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_)
+#define AFX_KRBREALMNAMEMAINTENANCE_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CKrbRealmHostMaintenance dialog
+
+#include "resource.h"
+#include "CLeashDragListBox.h"
+
+#define MAXLINE 256
+
+class CKrbRealmHostMaintenance : public CPropertyPage
+{
+// Construction
+private:
+       DECLARE_DYNCREATE(CKrbRealmHostMaintenance)
+       CHAR lineBuf[MAXLINE];
+       CString m_theAdminServerMarked;
+       CString m_theAdminServer;
+       BOOL m_isRealmListBoxInFocus;
+       BOOL m_isStart;
+    BOOL m_initDnsKdcLookup;
+    BOOL m_newDnsKdcLookup;
+
+       bool OnButtonKdchostAddInternal();
+
+       //void ResetDefaultRealmComboBox();
+
+public:
+       //CKrbRealmHostMaintenance(CWnd* pParent = NULL);   // standard constructor
+       CKrbRealmHostMaintenance();
+       virtual ~CKrbRealmHostMaintenance();
+
+// Dialog Data
+       //{{AFX_DATA(CKrbRealmHostMaintenance)
+       enum { IDD = IDD_KRB_REALMHOST_MAINT };
+       CListBox        m_KDCRealmList;
+       CLeashDragListBox m_KDCHostList;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CKrbRealmHostMaintenance)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CKrbRealmHostMaintenance)
+       virtual BOOL OnInitDialog();
+       virtual BOOL OnApply();
+       virtual void OnCancel();
+       afx_msg void OnButtonRealmHostAdd();
+       afx_msg void OnButtonRealmHostEdit();
+       afx_msg void OnButtonRealmHostRemove();
+       afx_msg void OnSelchangeListKdcRealm();
+       afx_msg void OnButtonAdminserver();
+       afx_msg void OnSetfocusListKdcRealm();
+       afx_msg void OnButtonKdchostAdd();
+       afx_msg void OnButtonKdchostRemove();
+       afx_msg void OnButtonRemoveAdminserver();
+       afx_msg void OnSelchangeListKdcHost();
+       afx_msg void OnButtonKdchostEdit();
+       afx_msg void OnDblclkListKdcRealm();
+       afx_msg void OnDblclkListKdcHost();
+       afx_msg void OnButtonRealmhostMaintHelp();
+    afx_msg void OnCheckDnsKdcLookup();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_KRBREALMNAMEMAINTENANCE_H__2FE711C3_8E9A_11D2_94C5_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/Leash.cpp b/src/windows/leash/Leash.cpp
new file mode 100644 (file)
index 0000000..eb2c110
--- /dev/null
@@ -0,0 +1,1618 @@
+//**************************************************************************
+// File:       Leash.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  1998 Massachusetts Institute of Technology - All rights
+//             reserved.
+//
+// Description:        CPP file for Leash.h. Contains variables and functions
+//             for Leash
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 12/02/98    ADL     Original
+//**************************************************************************
+
+#include "stdafx.h"
+#include "Leash.h"
+
+#include "MainFrm.h"
+#include "LeashDoc.h"
+#include "LeashView.h"
+#include "LeashAboutBox.h"
+
+#include "reminder.h"
+#include "mitwhich.h"
+#include <leasherr.h>
+#include "lglobals.h"
+#include <krb5.h>
+#include <com_err.h>
+
+#include <wshelper.h>
+
+#ifndef NO_AFS
+#include "afscompat.h"
+#endif
+
+#include <errno.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+extern "C" int VScheckVersion(HWND hWnd, HANDLE hThisInstance);
+
+TicketInfoWrapper ticketinfo;
+#ifndef KRB5_TC_NOTICKET  /* test for krb5 1.4 and thread safety */
+HANDLE m_tgsReqMutex = 0;
+#endif
+
+HWND CLeashApp::m_hProgram = 0;
+HINSTANCE CLeashApp::m_hLeashDLL = 0;
+HINSTANCE CLeashApp::m_hKrb4DLL = 0;
+HINSTANCE CLeashApp::m_hKrb5DLL = 0;
+HINSTANCE CLeashApp::m_hKrb5ProfileDLL= 0;
+HINSTANCE CLeashApp::m_hAfsDLL = 0;
+HINSTANCE CLeashApp::m_hPsapi = 0;
+HINSTANCE CLeashApp::m_hToolHelp32 = 0;
+krb5_context CLeashApp::m_krbv5_context = 0;
+profile_t CLeashApp::m_krbv5_profile = 0;
+HINSTANCE CLeashApp::m_hKrbLSA = 0;
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashApp
+
+
+BEGIN_MESSAGE_MAP(CLeashApp, CWinApp)
+       //{{AFX_MSG_MAP(CLeashApp)
+       //}}AFX_MSG_MAP
+       // Standard file based document commands
+       ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
+       ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashApp construction
+CLeashApp::CLeashApp()
+{
+    m_krbv5_context = NULL;
+    m_krbv5_profile = NULL;
+    // TODO: add construction code here,
+    // Place all significant initialization in InitInstance
+
+    // Memory may not be initialized to zeros (in debug)
+    memset(&ticketinfo, 0, sizeof(ticketinfo));
+
+    ticketinfo.lockObj = CreateMutex(NULL, FALSE, NULL);
+#ifndef KRB5_TC_NOTICKET
+    m_tgsReqMutex = CreateMutex(NULL, FALSE, NULL);
+#endif
+
+#ifdef USE_HTMLHELP
+#if _MSC_VER >= 1300
+    EnableHtmlHelp();
+#endif
+#endif
+}
+
+CLeashApp::~CLeashApp()
+{
+    if ( m_krbv5_context ) {
+        pkrb5_free_context(m_krbv5_context);
+        m_krbv5_context = NULL;
+    }
+
+    if ( m_krbv5_profile ) {
+        pprofile_release(m_krbv5_profile);
+        m_krbv5_profile = NULL;
+    }
+
+#ifdef COMMENT
+       /* Do not free the locking objects.  Doing so causes an invalid handle access */
+    CloseHandle(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+    CloseHandle(m_tgsReqMutex);
+#endif
+#endif
+       AfxFreeLibrary(m_hLeashDLL);
+       AfxFreeLibrary(m_hKrb4DLL);
+       AfxFreeLibrary(m_hKrb5DLL);
+       AfxFreeLibrary(m_hKrb5ProfileDLL);
+       AfxFreeLibrary(m_hAfsDLL);
+       AfxFreeLibrary(m_hPsapi);
+    AfxFreeLibrary(m_hToolHelp32);
+    AfxFreeLibrary(m_hKrbLSA);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CLeashApp object
+
+CLeashApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashApp initialization
+
+void CLeashApp::ParseParam (LPCTSTR lpszParam,BOOL bFlag,BOOL bLast)
+{
+       //CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast) ;
+}
+
+extern "C" {
+    LRESULT WINAPI LeashWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+    {
+        switch ( Msg ) {
+        case WM_SYSCOMMAND:
+            if (SC_CLOSE == (wParam & 0xfff0)) {
+                wParam = (wParam & ~0xfff0) | SC_MINIMIZE;
+            }
+            break;
+        }
+        return ::DefWindowProc(hWnd, Msg, wParam, lParam);
+    }
+}
+
+BOOL CLeashApp::InitInstance()
+{
+    // NOTE: Not used at this time
+    /// Set LEASH_DLL to the path where the Leash.exe is
+    char modulePath[MAX_PATH];
+    DWORD result = GetModuleFileName(AfxGetInstanceHandle(), modulePath, MAX_PATH);
+    ASSERT(result);
+
+    char* pPath = modulePath + strlen(modulePath) - 1;
+    while (*pPath != '\\')
+    {
+        *pPath = 0;
+        pPath--;
+    }
+    strcat(modulePath, LEASH_HELP_FILE);
+    m_helpFile = modulePath;
+
+    ///strcat(dllFile, LEASH_DLL);
+    ///m_leashDLL = dllFile;
+
+    BOOL autoInit = FALSE;
+    HWND hMsg = GetForegroundWindow();
+    if (!InitDLLs())
+        return FALSE; //exit program, can't load LEASHDLL
+
+    // Check for args (switches)
+    LPCTSTR exeFile            = __targv[0];
+    LPCTSTR optionParam =  __targv[1];
+
+    if (optionParam)
+    {
+        if (*optionParam  == '-' || *optionParam  == '/')
+        {
+            if (0 == stricmp(optionParam+1, "kinit") ||
+                0 == stricmp(optionParam+1, "i"))
+            {
+                LSH_DLGINFO_EX ldi;
+                               char username[64]="";
+                               char realm[192]="";
+                               int i=0, j=0;
+                TicketList* ticketList = NULL;
+                if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+                    throw("Unable to lock ticketinfo");
+
+                pLeashKRB5GetTickets(&ticketinfo.Krb5, &ticketList,
+                                      &CLeashApp::m_krbv5_context);
+                pLeashFreeTicketList(&ticketList);
+                pLeashKRB4GetTickets(&ticketinfo.Krb4, &ticketList);
+                pLeashFreeTicketList(&ticketList);
+
+                if ( ticketinfo.Krb5.btickets && ticketinfo.Krb5.principal[0] ) {
+                    for (; ticketinfo.Krb5.principal[i] && ticketinfo.Krb5.principal[i] != '@'; i++)
+                    {
+                        username[i] = ticketinfo.Krb5.principal[i];
+                    }
+                    username[i] = '\0';
+                    if (ticketinfo.Krb5.principal[i]) {
+                        for (i++ ; ticketinfo.Krb5.principal[i] ; i++, j++)
+                        {
+                            realm[j] = ticketinfo.Krb5.principal[i];
+                        }
+                    }
+                    realm[j] = '\0';
+                } else if ( ticketinfo.Krb4.btickets && ticketinfo.Krb4.principal[0] ) {
+                    for (; ticketinfo.Krb4.principal[i] && ticketinfo.Krb4.principal[i] != '@'; i++)
+                    {
+                        username[i] = ticketinfo.Krb4.principal[i];
+                    }
+                    username[i] = '\0';
+                    if (ticketinfo.Krb4.principal[i]) {
+                        for (i++ ; ticketinfo.Krb4.principal[i] ; i++, j++)
+                        {
+                            realm[j] = ticketinfo.Krb4.principal[i];
+                        }
+                    }
+                    realm[j] = '\0';
+                }
+                ReleaseMutex(ticketinfo.lockObj);
+
+                               ldi.size = sizeof(ldi);
+                               ldi.dlgtype = DLGTYPE_PASSWD;
+                ldi.title = "Initialize Ticket";
+                ldi.username = username;
+                               ldi.realm = realm;
+                ldi.dlgtype = DLGTYPE_PASSWD;
+                ldi.use_defaults = 1;
+
+                if (!pLeash_kinit_dlg_ex(hMsg, &ldi))
+                {
+                    MessageBox(hMsg, "There was an error getting tickets!",
+                               "Error", MB_OK);
+                    return FALSE;
+                }
+                return TRUE;
+            }
+            else if (0 == stricmp(optionParam+1, "ms2mit") ||
+                     0 == stricmp(optionParam+1, "import") ||
+                     0 == stricmp(optionParam+1, "m"))
+            {
+                if (!pLeash_importable()) {
+                    MessageBox(hMsg,
+                               "The Microsoft Logon Session does not support importing Ticket Getting Tickets!",
+                               "Error", MB_OK);
+                    return FALSE;
+                }
+
+                if (!pLeash_import())
+                {
+                    MessageBox(hMsg,
+                               "There was an error importing tickets from the Microsoft Logon Session!",
+                               "Error", MB_OK);
+                    return FALSE;
+                }
+                return TRUE;
+            }
+            else if (0 == stricmp(optionParam+1, "destroy") ||
+                     0 == stricmp(optionParam+1, "d"))
+            {
+                if (pLeash_kdestroy())
+                {
+                    MessageBox(hMsg,
+                               "There was an error destroying tickets!",
+                               "Error", MB_OK);
+                    return FALSE;
+                }
+                return TRUE;
+            }
+            else if (0 == stricmp(optionParam+1, "renew") ||
+                     0 == stricmp(optionParam+1, "r"))
+            {
+                if (!pLeash_renew())
+                {
+                    MessageBox(hMsg,
+                               "There was an error renewing tickets!",
+                               "Error", MB_OK);
+                    return FALSE;
+                }
+                return TRUE;
+            }
+            else if (0 == stricmp(optionParam+1, "autoinit") ||
+                     0 == stricmp(optionParam+1, "a"))
+            {
+                autoInit = TRUE;
+            }
+            else
+            {
+                MessageBox(hMsg,
+                           "'-kinit' or '-i' to perform ticket initialization (and exit)\n"
+                            "'-renew' or '-r' to perform ticket renewal (and exit)\n"
+                            "'-destroy' or '-d' to perform ticket destruction (and exit)\n"
+                            "'-autoinit' or '-a' to perform automatic ticket initialization\n"
+                            "'-ms2mit' or '-import' or '-m' to perform ticket importation (and exit)",
+                           "Leash Error", MB_OK);
+                return FALSE;
+            }
+        }
+        else
+        {
+            MessageBox(hMsg,
+                        "'-kinit' or '-i' to perform ticket initialization (and exit)\n"
+                        "'-renew' or '-r' to perform ticket renewal (and exit)\n"
+                        "'-destroy' or '-d' to perform ticket destruction (and exit)\n"
+                        "'-autoinit' or '-a' to perform automatic ticket initialization\n"
+                        "'-ms2mit' or '-import' or '-m' to perform ticket importation (and exit)",
+                       "Leash Error", MB_OK);
+            return FALSE;
+        }
+    }
+
+    // Insure only one instance of Leash
+    if (!FirstInstance())
+        return FALSE;
+
+    //register our unique wnd class name to find it later
+    WNDCLASS wndcls;
+    memset(&wndcls, 0, sizeof(WNDCLASS));
+    wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
+    wndcls.lpfnWndProc = ::LeashWindowProc;
+    wndcls.hInstance = AfxGetInstanceHandle();
+    wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
+    wndcls.hCursor = LoadCursor(IDC_ARROW);
+    wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+    wndcls.lpszMenuName = NULL;
+    //now the wnd class name to find it
+    wndcls.lpszClassName = _T("LEASH.0WNDCLASS");
+
+    //register the new class
+    if(!AfxRegisterClass(&wndcls))
+    {
+        TRACE("Class registration failed\n");
+        return FALSE;
+    }
+
+    AfxEnableControlContainer();
+
+       // Standard initialization
+       // If you are not using these features and wish to reduce the size
+       //  of your final executable, you should remove from the following
+       //  the specific initialization routines you do not need.
+
+#if _MSC_VER < 1300
+#ifdef _AFXDLL
+    Enable3dControls();                        // Call this when using MFC in a shared DLL
+#else
+    Enable3dControlsStatic();  // Call this when linking to MFC statically
+#endif
+#endif
+
+    // Registry key under which our settings are stored.
+    if (m_pszAppName)
+        free((void*)m_pszAppName);
+    m_pszAppName = _tcsdup("Leash32");
+    SetRegistryKey(_T("MIT"));
+
+    LoadStdProfileSettings(); // Load standard INI file options (including MRU)
+
+    // Register the application's document templates.  Document templates
+    //  serve as the connection between documents, frame windows and views.
+
+    CSingleDocTemplate* pDocTemplate;
+    pDocTemplate = new CSingleDocTemplate(
+        IDR_MAINFRAME,
+        RUNTIME_CLASS(LeashDoc),
+        RUNTIME_CLASS(CMainFrame),       // main SDI frame window
+        RUNTIME_CLASS(CLeashView));
+    AddDocTemplate(pDocTemplate);
+
+       // Parse command line for standard shell commands, DDE, file open
+    CCommandLineInfo cmdInfo;
+    ParseCommandLine(cmdInfo);
+
+       // Dispatch commands specified on the command line
+    if (!ProcessShellCommand(cmdInfo))
+        return FALSE;
+
+    // Check to see if there are any tickets in the cache
+    // If not and the Windows Logon Session is Kerberos authenticated attempt an import
+    {
+        TicketList* ticketList = NULL;
+        if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+            throw("Unable to lock ticketinfo");
+        pLeashKRB5GetTickets(&ticketinfo.Krb5, &ticketList, &CLeashApp::m_krbv5_context);
+        pLeashFreeTicketList(&ticketList);
+        pLeashKRB4GetTickets(&ticketinfo.Krb4, &ticketList);
+        pLeashFreeTicketList(&ticketList);
+        BOOL b_autoinit = !ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets;
+        ReleaseMutex(ticketinfo.lockObj);
+
+        DWORD dwMsLsaImport = pLeash_get_default_mslsa_import();
+
+        if ( b_autoinit && dwMsLsaImport && pLeash_importable() ) {
+            // We have the option of importing tickets from the MSLSA
+            // but should we?  Do the tickets in the MSLSA cache belong
+            // to the default realm used by Leash?  If so, import.
+            int import = 0;
+
+            if ( dwMsLsaImport == 1 ) {             /* always import */
+                import = 1;
+            } else if ( dwMsLsaImport == 2 ) {      /* import when realms match */
+                krb5_error_code code;
+                krb5_ccache mslsa_ccache=0;
+                krb5_principal princ = 0;
+                char ms_realm[128] = "", *def_realm = 0, *r;
+                int i;
+
+                if (code = pkrb5_cc_resolve(CLeashApp::m_krbv5_context, "MSLSA:", &mslsa_ccache))
+                    goto cleanup;
+
+                if (code = pkrb5_cc_get_principal(CLeashApp::m_krbv5_context, mslsa_ccache, &princ))
+                    goto cleanup;
+
+                for ( r=ms_realm, i=0; i<krb5_princ_realm(CLeashApp::m_krb5v5_context, princ)->length; r++, i++ ) {
+                    *r = krb5_princ_realm(CLeashApp::m_krb5v5_context, princ)->data[i];
+                }
+                *r = '\0';
+
+                if (code = pkrb5_get_default_realm(CLeashApp::m_krbv5_context, &def_realm))
+                    goto cleanup;
+
+                import = !strcmp(def_realm, ms_realm);
+
+              cleanup:
+                if (def_realm)
+                    pkrb5_free_default_realm(CLeashApp::m_krbv5_context, def_realm);
+
+                if (princ)
+                    pkrb5_free_principal(CLeashApp::m_krbv5_context, princ);
+
+                if (mslsa_ccache)
+                    pkrb5_cc_close(CLeashApp::m_krbv5_context, mslsa_ccache);
+            }
+
+            if (import && pLeash_import()) {
+                CLeashView::m_importedTickets = 1;
+                ::PostMessage(m_pMainWnd->m_hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+                b_autoinit = FALSE;
+            }
+        }
+
+        if (autoInit) {
+            if ( b_autoinit )
+                AfxBeginThread(InitWorker, m_pMainWnd->m_hWnd);
+
+            IpAddrChangeMonitorInit(m_pMainWnd->m_hWnd);
+        }
+    }
+
+    VScheckVersion(m_pMainWnd->m_hWnd, AfxGetInstanceHandle());
+
+    // The one and only window has been initialized, so show and update it.
+    m_pMainWnd->SetWindowText("Leash");
+    m_pMainWnd->UpdateWindow();
+    m_pMainWnd->ShowWindow(SW_SHOW);
+    m_pMainWnd->SetForegroundWindow();
+
+    ValidateConfigFiles();
+
+    return TRUE;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashApp commands
+
+// leash functions
+DECL_FUNC_PTR(not_an_API_LeashKRB4GetTickets);
+DECL_FUNC_PTR(not_an_API_LeashKRB5GetTickets);
+DECL_FUNC_PTR(not_an_API_LeashAFSGetToken);
+DECL_FUNC_PTR(not_an_API_LeashFreeTicketList);
+DECL_FUNC_PTR(not_an_API_LeashGetTimeServerName);
+DECL_FUNC_PTR(Leash_kdestroy);
+DECL_FUNC_PTR(Leash_changepwd_dlg);
+DECL_FUNC_PTR(Leash_changepwd_dlg_ex);
+DECL_FUNC_PTR(Leash_kinit_dlg);
+DECL_FUNC_PTR(Leash_kinit_dlg_ex);
+DECL_FUNC_PTR(Leash_timesync);
+DECL_FUNC_PTR(Leash_get_default_lifetime);
+DECL_FUNC_PTR(Leash_set_default_lifetime);
+DECL_FUNC_PTR(Leash_get_default_forwardable);
+DECL_FUNC_PTR(Leash_set_default_forwardable);
+DECL_FUNC_PTR(Leash_get_default_renew_till);
+DECL_FUNC_PTR(Leash_set_default_renew_till);
+DECL_FUNC_PTR(Leash_get_default_noaddresses);
+DECL_FUNC_PTR(Leash_set_default_noaddresses);
+DECL_FUNC_PTR(Leash_get_default_proxiable);
+DECL_FUNC_PTR(Leash_set_default_proxiable);
+DECL_FUNC_PTR(Leash_get_default_publicip);
+DECL_FUNC_PTR(Leash_set_default_publicip);
+DECL_FUNC_PTR(Leash_get_default_use_krb4);
+DECL_FUNC_PTR(Leash_set_default_use_krb4);
+DECL_FUNC_PTR(Leash_get_default_life_min);
+DECL_FUNC_PTR(Leash_set_default_life_min);
+DECL_FUNC_PTR(Leash_get_default_life_max);
+DECL_FUNC_PTR(Leash_set_default_life_max);
+DECL_FUNC_PTR(Leash_get_default_renew_min);
+DECL_FUNC_PTR(Leash_set_default_renew_min);
+DECL_FUNC_PTR(Leash_get_default_renew_max);
+DECL_FUNC_PTR(Leash_set_default_renew_max);
+DECL_FUNC_PTR(Leash_get_default_renewable);
+DECL_FUNC_PTR(Leash_set_default_renewable);
+DECL_FUNC_PTR(Leash_get_lock_file_locations);
+DECL_FUNC_PTR(Leash_set_lock_file_locations);
+DECL_FUNC_PTR(Leash_get_default_uppercaserealm);
+DECL_FUNC_PTR(Leash_set_default_uppercaserealm);
+DECL_FUNC_PTR(Leash_get_default_mslsa_import);
+DECL_FUNC_PTR(Leash_set_default_mslsa_import);
+DECL_FUNC_PTR(Leash_get_default_preserve_kinit_settings);
+DECL_FUNC_PTR(Leash_set_default_preserve_kinit_settings);
+DECL_FUNC_PTR(Leash_import);
+DECL_FUNC_PTR(Leash_importable);
+DECL_FUNC_PTR(Leash_renew);
+DECL_FUNC_PTR(Leash_reset_defaults);
+
+FUNC_INFO leash_fi[] = {
+    MAKE_FUNC_INFO(not_an_API_LeashKRB4GetTickets),
+    MAKE_FUNC_INFO(not_an_API_LeashKRB5GetTickets),
+    MAKE_FUNC_INFO(not_an_API_LeashAFSGetToken),
+    MAKE_FUNC_INFO(not_an_API_LeashFreeTicketList),
+    MAKE_FUNC_INFO(not_an_API_LeashGetTimeServerName),
+    MAKE_FUNC_INFO(Leash_kdestroy),
+    MAKE_FUNC_INFO(Leash_changepwd_dlg),
+    MAKE_FUNC_INFO(Leash_changepwd_dlg_ex),
+    MAKE_FUNC_INFO(Leash_kinit_dlg),
+       MAKE_FUNC_INFO(Leash_kinit_dlg_ex),
+    MAKE_FUNC_INFO(Leash_timesync),
+    MAKE_FUNC_INFO(Leash_get_default_lifetime),
+    MAKE_FUNC_INFO(Leash_set_default_lifetime),
+    MAKE_FUNC_INFO(Leash_get_default_renew_till),
+    MAKE_FUNC_INFO(Leash_set_default_renew_till),
+    MAKE_FUNC_INFO(Leash_get_default_forwardable),
+    MAKE_FUNC_INFO(Leash_set_default_forwardable),
+    MAKE_FUNC_INFO(Leash_get_default_noaddresses),
+    MAKE_FUNC_INFO(Leash_set_default_noaddresses),
+    MAKE_FUNC_INFO(Leash_get_default_proxiable),
+    MAKE_FUNC_INFO(Leash_set_default_proxiable),
+    MAKE_FUNC_INFO(Leash_get_default_publicip),
+    MAKE_FUNC_INFO(Leash_set_default_publicip),
+    MAKE_FUNC_INFO(Leash_get_default_use_krb4),
+    MAKE_FUNC_INFO(Leash_set_default_use_krb4),
+    MAKE_FUNC_INFO(Leash_get_default_life_min),
+    MAKE_FUNC_INFO(Leash_set_default_life_min),
+    MAKE_FUNC_INFO(Leash_get_default_life_max),
+    MAKE_FUNC_INFO(Leash_set_default_life_max),
+    MAKE_FUNC_INFO(Leash_get_default_renew_min),
+    MAKE_FUNC_INFO(Leash_set_default_renew_min),
+    MAKE_FUNC_INFO(Leash_get_default_renew_max),
+    MAKE_FUNC_INFO(Leash_set_default_renew_max),
+    MAKE_FUNC_INFO(Leash_get_default_renewable),
+    MAKE_FUNC_INFO(Leash_set_default_renewable),
+    MAKE_FUNC_INFO(Leash_get_lock_file_locations),
+    MAKE_FUNC_INFO(Leash_set_lock_file_locations),
+    MAKE_FUNC_INFO(Leash_get_default_uppercaserealm),
+    MAKE_FUNC_INFO(Leash_set_default_uppercaserealm),
+    MAKE_FUNC_INFO(Leash_get_default_mslsa_import),
+    MAKE_FUNC_INFO(Leash_set_default_mslsa_import),
+    MAKE_FUNC_INFO(Leash_get_default_preserve_kinit_settings),
+    MAKE_FUNC_INFO(Leash_set_default_preserve_kinit_settings),
+    MAKE_FUNC_INFO(Leash_import),
+    MAKE_FUNC_INFO(Leash_importable),
+    MAKE_FUNC_INFO(Leash_renew),
+    MAKE_FUNC_INFO(Leash_reset_defaults),
+    END_FUNC_INFO
+};
+
+// krb4 functions
+DECL_FUNC_PTR(set_krb_debug);
+DECL_FUNC_PTR(set_krb_ap_req_debug);
+DECL_FUNC_PTR(krb_get_krbconf2);
+DECL_FUNC_PTR(krb_get_krbrealm2);
+DECL_FUNC_PTR(tkt_string);
+DECL_FUNC_PTR(krb_set_tkt_string);
+DECL_FUNC_PTR(krb_realmofhost);
+DECL_FUNC_PTR(krb_get_lrealm);
+DECL_FUNC_PTR(krb_get_krbhst);
+DECL_FUNC_PTR(tf_init);
+DECL_FUNC_PTR(tf_close);
+DECL_FUNC_PTR(krb_get_tf_realm);
+
+FUNC_INFO krb4_fi[] = {
+    MAKE_FUNC_INFO(set_krb_debug),
+    MAKE_FUNC_INFO(set_krb_ap_req_debug),
+    MAKE_FUNC_INFO(krb_get_krbconf2),
+    MAKE_FUNC_INFO(krb_get_krbrealm2),
+    MAKE_FUNC_INFO(tkt_string),
+    MAKE_FUNC_INFO(krb_set_tkt_string),
+    MAKE_FUNC_INFO(krb_realmofhost),
+    MAKE_FUNC_INFO(krb_get_lrealm),
+    MAKE_FUNC_INFO(krb_get_krbhst),
+    MAKE_FUNC_INFO(tf_init),
+    MAKE_FUNC_INFO(tf_close),
+    MAKE_FUNC_INFO(krb_get_tf_realm),
+    END_FUNC_INFO
+};
+
+
+// psapi functions
+DECL_FUNC_PTR(GetModuleFileNameExA);
+DECL_FUNC_PTR(EnumProcessModules);
+
+FUNC_INFO psapi_fi[] = {
+    MAKE_FUNC_INFO(GetModuleFileNameExA),
+    MAKE_FUNC_INFO(EnumProcessModules),
+    END_FUNC_INFO
+};
+
+// toolhelp functions
+DECL_FUNC_PTR(CreateToolhelp32Snapshot);
+DECL_FUNC_PTR(Module32First);
+DECL_FUNC_PTR(Module32Next);
+
+FUNC_INFO toolhelp_fi[] = {
+    MAKE_FUNC_INFO(CreateToolhelp32Snapshot),
+    MAKE_FUNC_INFO(Module32First),
+    MAKE_FUNC_INFO(Module32Next),
+    END_FUNC_INFO
+};
+
+// krb5 functions
+DECL_FUNC_PTR(krb5_cc_default_name);
+DECL_FUNC_PTR(krb5_cc_set_default_name);
+DECL_FUNC_PTR(krb5_get_default_config_files);
+DECL_FUNC_PTR(krb5_free_config_files);
+DECL_FUNC_PTR(krb5_free_context);
+DECL_FUNC_PTR(krb5_get_default_realm);
+DECL_FUNC_PTR(krb5_free_default_realm);
+DECL_FUNC_PTR(krb5_init_context);
+DECL_FUNC_PTR(krb5_cc_default);
+DECL_FUNC_PTR(krb5_parse_name);
+DECL_FUNC_PTR(krb5_free_principal);
+DECL_FUNC_PTR(krb5_cc_close);
+DECL_FUNC_PTR(krb5_cc_get_principal);
+DECL_FUNC_PTR(krb5_build_principal);
+DECL_FUNC_PTR(krb5_c_random_make_octets);
+DECL_FUNC_PTR(krb5_get_init_creds_password);
+DECL_FUNC_PTR(krb5_free_cred_contents);
+DECL_FUNC_PTR(krb5_cc_resolve);
+DECL_FUNC_PTR(krb5_unparse_name);
+DECL_FUNC_PTR(krb5_free_unparsed_name);
+
+FUNC_INFO krb5_fi[] = {
+    MAKE_FUNC_INFO(krb5_cc_default_name),
+    MAKE_FUNC_INFO(krb5_cc_set_default_name),
+    MAKE_FUNC_INFO(krb5_get_default_config_files),
+    MAKE_FUNC_INFO(krb5_free_config_files),
+    MAKE_FUNC_INFO(krb5_free_context),
+    MAKE_FUNC_INFO(krb5_get_default_realm),
+    MAKE_FUNC_INFO(krb5_free_default_realm),
+    MAKE_FUNC_INFO(krb5_init_context),
+    MAKE_FUNC_INFO(krb5_cc_default),
+    MAKE_FUNC_INFO(krb5_parse_name),
+    MAKE_FUNC_INFO(krb5_free_principal),
+    MAKE_FUNC_INFO(krb5_cc_close),
+    MAKE_FUNC_INFO(krb5_cc_get_principal),
+    MAKE_FUNC_INFO(krb5_build_principal),
+    MAKE_FUNC_INFO(krb5_c_random_make_octets),
+    MAKE_FUNC_INFO(krb5_get_init_creds_password),
+    MAKE_FUNC_INFO(krb5_free_cred_contents),
+    MAKE_FUNC_INFO(krb5_cc_resolve),
+    MAKE_FUNC_INFO(krb5_unparse_name),
+    MAKE_FUNC_INFO(krb5_free_unparsed_name),
+    END_FUNC_INFO
+};
+
+// profile functions
+DECL_FUNC_PTR(profile_release);
+DECL_FUNC_PTR(profile_init);
+DECL_FUNC_PTR(profile_flush);
+DECL_FUNC_PTR(profile_rename_section);
+DECL_FUNC_PTR(profile_update_relation);
+DECL_FUNC_PTR(profile_clear_relation);
+DECL_FUNC_PTR(profile_add_relation);
+DECL_FUNC_PTR(profile_get_relation_names);
+DECL_FUNC_PTR(profile_get_subsection_names);
+DECL_FUNC_PTR(profile_get_values);
+DECL_FUNC_PTR(profile_free_list);
+DECL_FUNC_PTR(profile_abandon);
+DECL_FUNC_PTR(profile_get_string);
+DECL_FUNC_PTR(profile_release_string);
+
+FUNC_INFO profile_fi[] = {
+    MAKE_FUNC_INFO(profile_release),
+    MAKE_FUNC_INFO(profile_init),
+    MAKE_FUNC_INFO(profile_flush),
+    MAKE_FUNC_INFO(profile_rename_section),
+    MAKE_FUNC_INFO(profile_update_relation),
+    MAKE_FUNC_INFO(profile_clear_relation),
+    MAKE_FUNC_INFO(profile_add_relation),
+    MAKE_FUNC_INFO(profile_get_relation_names),
+    MAKE_FUNC_INFO(profile_get_subsection_names),
+    MAKE_FUNC_INFO(profile_get_values),
+    MAKE_FUNC_INFO(profile_free_list),
+    MAKE_FUNC_INFO(profile_abandon),
+    MAKE_FUNC_INFO(profile_get_string),
+    MAKE_FUNC_INFO(profile_release_string),
+    END_FUNC_INFO
+};
+
+// Tries to load the .DLL files.  If it works, we get some functions from them
+// and return a TRUE.  If it doesn't work, we return a FALSE.
+BOOL CLeashApp::InitDLLs()
+{
+    m_hLeashDLL = AfxLoadLibrary(LEASHDLL);
+    m_hKrb4DLL = AfxLoadLibrary(KERB4DLL);
+    m_hKrb5DLL = AfxLoadLibrary(KERB5DLL);
+    m_hKrb5ProfileDLL = AfxLoadLibrary(KERB5_PPROFILE_DLL);
+
+#ifndef NO_AFS
+    afscompat_init();
+    m_hAfsDLL = AfxLoadLibrary(AFSAuthentDLL());
+#endif
+
+#define PSAPIDLL "psapi.dll"
+#define TOOLHELPDLL "kernel32.dll"
+
+    m_hPsapi = AfxLoadLibrary(PSAPIDLL);
+    m_hToolHelp32 = AfxLoadLibrary(TOOLHELPDLL);
+
+    HWND hwnd = GetForegroundWindow();
+    if (!m_hLeashDLL)
+    {
+        // We couldn't load the m_hLeashDLL.
+        m_msgError = "Couldn't load the Leash DLL or one of its dependents.";
+        MessageBox(hwnd, m_msgError, "Error", MB_OK);
+        return FALSE;
+    }
+
+    if (!LoadFuncs(LEASHDLL, leash_fi, 0, 0, 1, 0, 0))
+    {
+        MessageBox(hwnd,
+                   "Functions within the Leash DLL didn't load properly!",
+                   "Error", MB_OK);
+        return FALSE;
+    }
+
+    if (m_hKrb4DLL)
+    {
+        if (!LoadFuncs(KERB4DLL, krb4_fi, 0, 0, 1, 0, 0))
+        {
+            MessageBox(hwnd,
+                       "Unexpected error while loading " KERB4DLL ".\n"
+                       "Kerberos 4 functionality will be disabled.\n",
+                       "Error", MB_OK);
+        }
+    }
+
+    if (m_hKrb5DLL)
+    {
+        if (!LoadFuncs(KERB5DLL, krb5_fi, 0, 0, 1, 0, 0))
+        {
+            MessageBox(hwnd,
+                       "Unexpected error while loading " KERB5DLL ".\n"
+                       "Kerberos 5 functionality will be disabled.\n",
+                       "Error", MB_OK);
+            AfxFreeLibrary(m_hKrb5DLL);
+            m_hKrb5DLL = 0;
+        }
+        else if (!m_hKrb5ProfileDLL ||
+                 !LoadFuncs(KERB5_PPROFILE_DLL, profile_fi, 0, 0, 1, 0, 0))
+        {
+            MessageBox(hwnd,
+                       "Unexpected error while loading "KERB5_PPROFILE_DLL".\n"
+                       "Kerberos 5 functionality will be disabled.\n",
+                       "Error", MB_OK);
+            AfxFreeLibrary(m_hKrb5ProfileDLL);
+            m_hKrb5ProfileDLL = 0;
+            // Use m_hKrb5DLL to undo LoadLibrary in loadfuncs...
+            UnloadFuncs(krb5_fi, m_hKrb5DLL);
+            AfxFreeLibrary(m_hKrb5DLL);
+            m_hKrb5DLL = 0;
+        }
+
+    }
+
+    OSVERSIONINFO osvi;
+    memset(&osvi, 0, sizeof(OSVERSIONINFO));
+    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    GetVersionEx(&osvi);
+
+    // XXX: We should really use feature testing, first
+    // checking for CreateToolhelp32Snapshot.  If that's
+    // not around, we try the psapi stuff.
+    //
+    // Only load LSA functions if on NT/2000/XP
+    if(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
+    {
+        // Windows 9x
+        AfxFreeLibrary(m_hPsapi);
+        m_hPsapi = NULL;
+        if (!m_hToolHelp32 ||
+            !LoadFuncs(TOOLHELPDLL, toolhelp_fi, 0, 0, 1, 0, 0))
+        {
+            MessageBox(hwnd, "Could not load " TOOLHELPDLL "!", "Error",
+                       MB_OK);
+            return FALSE;
+        }
+    }
+    else if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+    {
+        // Windows NT
+        AfxFreeLibrary(m_hToolHelp32);
+        m_hToolHelp32 = NULL;
+        if (!m_hPsapi ||
+            !LoadFuncs(PSAPIDLL, psapi_fi, 0, 0, 1, 0, 0))
+        {
+            MessageBox(hwnd, "Could not load " PSAPIDLL "!", "Error", MB_OK);
+            return FALSE;
+        }
+
+               m_hKrbLSA  = AfxLoadLibrary(SECUR32DLL);
+    }
+    else
+    {
+        MessageBox(hwnd,
+                   "Unrecognized Operating System!",
+                   "Error", MB_OK);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+
+BOOL CLeashApp::FirstInstance()
+{
+    CWnd* pWndprev;
+    CWnd* pWndchild;
+
+    //find if it exists
+    pWndprev = CWnd::FindWindow(_T("LEASH.0WNDCLASS"), NULL);
+    if (pWndprev)
+    {
+        //if it has popups
+        pWndchild = pWndprev->GetLastActivePopup();
+        //if iconic restore
+        if (pWndprev->IsIconic())
+            pWndprev->ShowWindow(SW_RESTORE);
+
+        //bring the wnd to foreground
+        pWndchild->SetForegroundWindow();
+
+        return FALSE;
+    }
+    //we could not find prev instance
+    else
+        return TRUE;
+}
+
+void
+CLeashApp::ValidateConfigFiles()
+{
+    CStdioFile krbCon;
+    char confname[257];
+    char realm[256]="";
+
+    CWinApp * pApp = AfxGetApp();
+    if (pApp)
+        if (!pApp->GetProfileInt("Settings", "CreateMissingConfig", FALSE_FLAG))
+            return;
+
+    if ( m_hKrb5DLL ) {
+        int krb_con_open = 0;
+
+        // Create the empty KRB5.INI file
+        if (!GetProfileFile(confname,sizeof(confname))) {
+            const char *filenames[2];
+                   filenames[0] = confname;
+                   filenames[1] = NULL;
+                   long retval = pprofile_init(filenames, &m_krbv5_profile);
+                       if (!retval)
+                               return;
+                       else if (retval == ENOENT) {
+                               FILE * f = fopen(confname,"w");
+                               if (f != NULL) {
+                                       fclose(f);
+                                       retval = pprofile_init(filenames, &m_krbv5_profile);
+                               }
+                       }
+
+
+            if ( !GetKrb4ConFile(confname,sizeof(confname)) ) {
+                if (!krbCon.Open(confname, CFile::modeNoTruncate | CFile::modeRead))
+                {
+                    if (krbCon.Open(confname, CFile::modeCreate | CFile::modeWrite))
+                    {
+                        krb_con_open = 1;
+                    }
+                }
+            }
+
+            const char*  lookupKdc[] = {"libdefaults", "dns_lookup_kdc", NULL};
+            const char*  lookupRealm[] = {"libdefaults", "dns_lookup_realm", NULL};
+            const char*  defRealm[] = {"libdefaults", "default_realm", NULL};
+            const char*  noAddresses[] = {"libdefaults", "noaddresses", NULL};
+
+            // activate DNS KDC Lookups
+            const char** names = lookupKdc;
+            retval = pprofile_add_relation(m_krbv5_profile,
+                                           names,
+                                           "true");
+
+            // activate No Addresses
+            names = noAddresses;
+            retval = pprofile_add_relation(m_krbv5_profile,
+                                           names,
+                                           "true");
+
+            // Get Windows 2000/XP/2003 Kerberos config
+            if ( m_hKrbLSA && m_hKrb5DLL )
+            {
+                char domain[256]="";
+                HKEY hk=0;
+                DWORD dwType, dwSize, dwIndex;
+
+                if ( !RegOpenKeyEx(HKEY_CURRENT_USER,
+                                    "Volatile Environment", 0,
+                                    KEY_READ, &hk) )
+                {
+                    dwSize = sizeof(domain);
+                    RegQueryValueEx(hk, "USERDNSDOMAIN", 0, 0, (LPBYTE)domain, &dwSize);
+                    RegCloseKey(hk);
+                }
+                else if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                             "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
+                             0, KEY_READ, &hk))
+                {
+
+                    dwSize = sizeof(domain);
+                    RegQueryValueEx( hk, "DefaultDomainName",
+                                     NULL, &dwType, (unsigned char *)&domain, &dwSize);
+                    RegCloseKey(hk);
+                }
+
+                char realmkey[256]="SYSTEM\\CurrentControlSet\\Control\\Lsa\\Kerberos\\Domains\\";
+                int  keylen = strlen(realmkey)-1;
+
+                if ( domain[0] ) {
+                    strncpy(realm,domain,256);
+                    realm[255] = '\0';
+                    if ( krb_con_open ) {
+                        krbCon.WriteString(realm);
+                        krbCon.WriteString("\n");
+                    }
+                    strncat(realmkey,domain,256-strlen(realmkey));
+                    realmkey[255] = '\0';
+                }
+
+                if ( domain[0] &&
+                     !RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                                   realmkey,
+                                   0,
+                                   KEY_READ,
+                                   &hk)
+                     )
+                {
+                    RegCloseKey(hk);
+
+                    realmkey[keylen] = '\0';
+                    RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                                 realmkey,
+                                 0,
+                                 KEY_READ|KEY_ENUMERATE_SUB_KEYS,
+                                 &hk);
+
+                    dwIndex = 0;
+                    unsigned char subkey[256];
+                    FILETIME ft;
+                    dwSize = 256;
+                    while ( ERROR_SUCCESS == RegEnumKeyEx(hk,dwIndex++,
+                                                          (char *)subkey,
+                                                          &dwSize,
+                                                          0,
+                                                          0,
+                                                          0,
+                                                          &ft) )
+                    {
+                        HKEY hksub;
+
+                        if ( !RegOpenKeyEx(hk,
+                                   (char *)subkey,
+                                   0,
+                                   KEY_READ,
+                                   &hksub) )
+                        {
+                            unsigned char * lpszValue = NULL, *p;
+                            dwSize = 0;
+                                                       dwType = 0;
+                            RegQueryValueEx( hksub, "KdcNames",
+                                             NULL, &dwType, lpszValue, &dwSize);
+                            if ( dwSize > 0 ) {
+                                lpszValue = (unsigned char *)malloc(dwSize+1);
+                                dwSize += 1;
+                                RegQueryValueEx( hksub, "KdcNames",
+                                                 NULL, &dwType, lpszValue, &dwSize);
+
+                                p = lpszValue;
+                                while ( *p ) {
+                                    const char*  realmKdc[] = {"realms", (const char *)subkey, "kdc", NULL};
+                                    names = realmKdc;
+                                    retval = pprofile_add_relation(m_krbv5_profile,
+                                                                    names,
+                                                                    (const char *)p);
+
+                                    if ( krb_con_open ) {
+                                        krbCon.WriteString((const char *)subkey);
+                                        krbCon.WriteString("\t");
+                                        krbCon.WriteString((const char *)p);
+                                        krbCon.WriteString("\n");
+                                    }
+
+                                    p += strlen((char*)p) + 1;
+                                }
+                                free(lpszValue);
+                            }
+                            RegCloseKey(hksub);
+                        }
+                    }
+                    RegCloseKey(hk);
+                }
+            } else {
+                // activate DNS Realm Lookups (temporarily)
+                names = lookupRealm;
+                retval = pprofile_add_relation(m_krbv5_profile,
+                                                names,
+                                                "true");
+            }
+
+            // Save to Kerberos Five config. file "Krb5.ini"
+            retval = pprofile_flush(m_krbv5_profile);
+
+
+            // Use DNS to retrieve the realm (if possible)
+            if (!realm[0]) {
+                krb5_context ctx = 0;
+                krb5_principal me = 0;
+                krb5_error_code code = 0;
+
+                code = pkrb5_init_context(&ctx);
+                if (code) goto no_k5_realm;
+
+                code = pkrb5_parse_name(ctx, "foo", &me);
+                if (code) goto no_k5_realm;
+
+                if ( krb5_princ_realm(ctx,me)->length < sizeof(realm) - 1) {
+                    memcpy(realm, krb5_princ_realm(ctx,me)->data,
+                            krb5_princ_realm(ctx,me)->length);
+                    realm[krb5_princ_realm(ctx,me)->length] = '\0';
+                }
+
+                if ( krb_con_open ) {
+                    krbCon.WriteString(realm);
+                    krbCon.WriteString("\n");
+                }
+
+              no_k5_realm:
+                if ( me )
+                    pkrb5_free_principal(ctx,me);
+                if ( ctx )
+                    pkrb5_free_context(ctx);
+            }
+
+            // disable DNS Realm Lookups
+            retval = pprofile_update_relation(m_krbv5_profile,
+                                             names,
+                                             "true", "false");
+
+            // save the default realm if it was discovered
+            if ( realm[0] ) {
+                names = defRealm;
+                retval = pprofile_add_relation(m_krbv5_profile,
+                                               names,
+                                               realm);
+
+                // It would be nice to be able to generate a list of KDCs
+                // but to do so based upon the contents of DNS would be
+                // wrong for several reasons:
+                // . it would make static the values inserted into DNS SRV
+                //   records
+                // . DNS cannot necessarily be trusted
+            }
+
+            // Save to Kerberos Five config. file "Krb5.ini"
+            retval = pprofile_flush(m_krbv5_profile);
+
+            pprofile_release(m_krbv5_profile);
+            m_krbv5_profile = NULL;
+
+            // Close KRB.CON file
+            if ( krb_con_open ) {
+                krbCon.WriteString(".KERBEROS.OPTION. dns\n");
+                krbCon.Close();
+            }
+
+            // Create the empty KRBREALM.CON file
+            if ( !GetKrb4RealmFile(confname,sizeof(confname)) ) {
+                if (!krbCon.Open(confname, CFile::modeNoTruncate | CFile::modeRead))
+                {
+                    if (krbCon.Open(confname, CFile::modeCreate | CFile::modeWrite))
+                    {
+                        krbCon.Close();
+                    }
+                } else
+                    krbCon.Close();
+            }
+
+        }
+    } else if ( m_hKrb4DLL ) {
+        if ( !realm[0] ) {
+            /* Open ticket file */
+            char * file = ptkt_string();
+            int k_errno;
+
+            if (file != NULL && file[0]) {
+                if ((k_errno = ptf_init(file, R_TKT_FIL)) == KSUCCESS) {
+                    /* Close ticket file */
+                    (void) ptf_close();
+
+                    k_errno = pkrb_get_tf_realm(file, realm);
+                }
+                if (k_errno != KSUCCESS) {
+                    k_errno = pkrb_get_lrealm(realm, 1);
+                }
+            }
+        }
+
+        if ( !GetKrb4ConFile(confname,sizeof(confname)) ) {
+            if (!krbCon.Open(confname, CFile::modeNoTruncate | CFile::modeRead))
+            {
+                if (krbCon.Open(confname, CFile::modeCreate | CFile::modeWrite))
+                {
+                    if ( realm[0] )
+                        krbCon.WriteString(realm);
+                    krbCon.WriteString("\n.KERBEROS.OPTION. dns\n");
+                    krbCon.Close();
+                }
+            } else
+                               krbCon.Close();
+        }
+
+        if ( !GetKrb4RealmFile(confname,sizeof(confname)) ) {
+            if (!krbCon.Open(confname, CFile::modeNoTruncate | CFile::modeRead))
+            {
+                if (krbCon.Open(confname, CFile::modeCreate | CFile::modeWrite))
+                {
+                    krbCon.Close();
+                }
+            } else
+                               krbCon.Close();
+        }
+    }
+}
+
+BOOL
+CLeashApp::GetKrb4ConFile(
+    LPSTR confname,
+    UINT szConfname
+    )
+{
+    if (m_hKrb5DLL && !m_hKrb4DLL)
+       { // hold krb.con where krb5.ini is located
+               CHAR krbConFile[MAX_PATH]="";
+           //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);
+        if (GetProfileFile(krbConFile, sizeof(krbConFile)))
+        {
+                   GetWindowsDirectory(krbConFile,sizeof(krbConFile));
+            krbConFile[MAX_PATH-1] = '\0';
+                       strncat(krbConFile,"\\KRB5.INI",sizeof(krbConFile)-strlen(krbConFile)-1);
+            krbConFile[MAX_PATH-1] = '\0';
+        }
+
+               LPSTR pFind = strrchr(krbConFile, '\\');
+               if (pFind)
+               {
+                       *pFind = 0;
+                       strncat(krbConFile, "\\",MAX_PATH-1);
+            krbConFile[MAX_PATH-1] = '\0';
+                       strncat(krbConFile, KRB_FILE,MAX_PATH-1);
+            krbConFile[MAX_PATH-1] = '\0';
+               }
+               else
+                 ASSERT(0);
+
+               strncpy(confname, krbConFile, szConfname);
+        confname[szConfname-1] = '\0';
+       }
+       else if (m_hKrb4DLL)
+       {
+        unsigned int size = szConfname;
+        memset(confname, '\0', szConfname);
+               if (!pkrb_get_krbconf2(confname, &size))
+               { // Error has happened
+                   GetWindowsDirectory(confname,szConfname);
+            confname[szConfname-1] = '\0';
+                       strncat(confname, "\\",szConfname);
+            confname[szConfname-1] = '\0';
+                       strncat(confname,KRB_FILE,szConfname);
+            confname[szConfname-1] = '\0';
+               }
+       }
+    return FALSE;
+}
+
+BOOL
+CLeashApp::GetKrb4RealmFile(
+    LPSTR confname,
+    UINT szConfname
+    )
+{
+    if (m_hKrb5DLL && !m_hKrb4DLL)
+       { // hold krb.con where krb5.ini is located
+               CHAR krbRealmConFile[MAX_PATH];
+               //strcpy(krbRealmConFile, CLeashApp::m_krbv5_profile->first_file->filename);
+               if (GetProfileFile(krbRealmConFile, sizeof(krbRealmConFile)))
+        {
+                   GetWindowsDirectory(krbRealmConFile,sizeof(krbRealmConFile));
+            krbRealmConFile[MAX_PATH-1] = '\0';
+                       strncat(krbRealmConFile,"\\KRB5.INI",sizeof(krbRealmConFile)-strlen(krbRealmConFile));
+            krbRealmConFile[MAX_PATH-1] = '\0';
+        }
+
+               LPSTR pFind = strrchr(krbRealmConFile, '\\');
+               if (pFind)
+               {
+                       *pFind = 0;
+                       strncat(krbRealmConFile, "\\",MAX_PATH-1-strlen(krbRealmConFile));
+            krbRealmConFile[MAX_PATH-1] = '\0';
+                       strncat(krbRealmConFile, KRBREALM_FILE,MAX_PATH-1-strlen(krbRealmConFile));
+            krbRealmConFile[MAX_PATH-1] = '\0';
+               }
+               else
+                 ASSERT(0);
+
+               strncpy(confname, krbRealmConFile, szConfname);
+        confname[szConfname-1] = '\0';
+       }
+       else if (m_hKrb4DLL)
+       {
+        unsigned int size = szConfname;
+        memset(confname, '\0', szConfname);
+        if (!pkrb_get_krbrealm2(confname, &size))
+               {
+                   GetWindowsDirectory(confname,szConfname);
+            confname[szConfname-1] = '\0';
+                       strncat(confname, "\\",szConfname-strlen(confname));
+            confname[szConfname-1] = '\0';
+                       strncat(confname,KRBREALM_FILE,szConfname-strlen(confname));
+            confname[szConfname-1] = '\0';
+            return TRUE;
+               }
+       }
+    return FALSE;
+}
+
+BOOL
+CLeashApp::GetProfileFile(
+    LPSTR confname,
+    UINT szConfname
+    )
+{
+    char **configFile = NULL;
+    if (!m_hKrb5DLL)
+        return NULL;
+
+    if (pkrb5_get_default_config_files(&configFile))
+    {
+        GetWindowsDirectory(confname,szConfname);
+        confname[szConfname-1] = '\0';
+        strncat(confname,"\\KRB5.INI",szConfname-strlen(confname));
+        confname[szConfname-1] = '\0';
+        return FALSE;
+    }
+
+    *confname = 0;
+
+    if (configFile)
+    {
+        strncpy(confname, *configFile, szConfname);
+        confname[szConfname-1] = '\0';
+        pkrb5_free_config_files(configFile);
+    }
+
+    if (!*confname)
+    {
+        GetWindowsDirectory(confname,szConfname);
+        confname[szConfname-1] = '\0';
+        strncat(confname,"\\KRB5.INI",szConfname-strlen(confname));
+        confname[szConfname-1] = '\0';
+    }
+
+    return FALSE;
+}
+
+#define PROBE_USERNAME               "KERBEROS-KDC-PROBE"
+#define PROBE_PASSWORD_LEN           16
+
+BOOL
+CLeashApp::ProbeKDC(void)
+{
+    krb5_context ctx=0;
+    krb5_ccache  cc=0;
+    krb5_principal principal = 0;
+    krb5_principal probeprinc = 0;
+    krb5_creds     creds;
+    krb5_error_code code;
+    krb5_data pwdata;
+    char   password[PROBE_PASSWORD_LEN+1];
+    long   success = FALSE;
+
+    if (!pkrb5_init_context)
+        return success;
+
+    memset(&creds, 0, sizeof(creds));
+
+    code = pkrb5_init_context(&ctx);
+    if (code)
+        goto cleanup;
+
+    code = pkrb5_cc_default(ctx, &cc);
+    if (code)
+        goto cleanup;
+
+    code = pkrb5_cc_get_principal(ctx, cc, &principal);
+    if ( code )
+        code = pkrb5_parse_name(ctx, "foo", &principal);
+    if ( code )
+        goto cleanup;
+
+    code = pkrb5_build_principal( ctx, &probeprinc,
+                                  krb5_princ_realm(ctx,principal)->length,
+                                  krb5_princ_realm(ctx,principal)->data,
+                                  PROBE_USERNAME, NULL, NULL);
+    if ( code )
+        goto cleanup;
+
+    pwdata.data = password;
+    pwdata.length = PROBE_PASSWORD_LEN;
+    code = pkrb5_c_random_make_octets(ctx, &pwdata);
+    if (code) {
+        int i;
+        for ( i=0 ; i<PROBE_PASSWORD_LEN ; i )
+            password[i] = 'x';
+    }
+    password[PROBE_PASSWORD_LEN] = '\0';
+
+    code = pkrb5_get_init_creds_password(ctx,
+                                         &creds,
+                                         probeprinc,
+                                         password, // password
+                                         NULL, // prompter
+                                         0, // prompter data
+                                         0, // start time
+                                         0, // service name
+                                         0  // no options
+                                         );
+
+    switch ( code ) {
+    case KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN:
+    case KRB5KDC_ERR_CLIENT_REVOKED:
+    case KRB5KDC_ERR_CLIENT_NOTYET:
+    case KRB5KDC_ERR_PREAUTH_FAILED:
+    case KRB5KDC_ERR_PREAUTH_REQUIRED:
+    case KRB5KDC_ERR_PADATA_TYPE_NOSUPP:
+        success = TRUE;
+        break;
+    }
+  cleanup:
+    if (creds.client == probeprinc)
+        creds.client = 0;
+    pkrb5_free_cred_contents(ctx, &creds);
+    if (principal)
+        pkrb5_free_principal(ctx,principal);
+    if (probeprinc)
+        pkrb5_free_principal(ctx,probeprinc);
+    if (cc)
+        pkrb5_cc_close(ctx,cc);
+    if (ctx)
+        pkrb5_free_context(ctx);
+    return success;
+}
+
+VOID
+CLeashApp::ObtainTicketsViaUserIfNeeded(HWND hWnd)
+{
+    TicketList* ticketList = NULL;
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+    pLeashKRB5GetTickets(&ticketinfo.Krb5, &ticketList, &CLeashApp::m_krbv5_context);
+    pLeashFreeTicketList(&ticketList);
+    pLeashKRB4GetTickets(&ticketinfo.Krb4, &ticketList);
+    pLeashFreeTicketList(&ticketList);
+
+    if ( !ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets ) {
+        ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+        if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+            throw("Unable to lock TGS mutex");
+#endif
+        if ( pLeash_importable() ) {
+            if (pLeash_import())
+                CLeashView::m_importedTickets = 1;
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+        }
+        else if ( ProbeKDC() ) {
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            LSH_DLGINFO_EX ldi;
+            ldi.size = sizeof(ldi);
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.title = "Initialize Ticket";
+            ldi.username = NULL;
+            ldi.realm = NULL;
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.use_defaults = 1;
+
+            pLeash_kinit_dlg_ex(hWnd, &ldi);
+        }
+#ifndef KRB5_TC_NOTICKET
+        else {
+            ReleaseMutex(m_tgsReqMutex);
+        }
+#endif
+    } else if ( ticketinfo.Krb5.btickets ) {
+        ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+        if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+            throw("Unable to TGS mutex");
+#endif
+        if ( CLeashView::m_importedTickets && pLeash_importable() ) {
+            if (pLeash_import())
+                CLeashView::m_importedTickets = 1;
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+        }
+        else if ( ProbeKDC() && !pLeash_renew() ) {
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            LSH_DLGINFO_EX ldi;
+            ldi.size = sizeof(ldi);
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.title = "Initialize Ticket";
+            ldi.username = NULL;
+            ldi.realm = NULL;
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.use_defaults = 1;
+
+            pLeash_kinit_dlg_ex(hWnd, &ldi);
+        }
+#ifndef KRB5_TC_NOTICKET
+        else {
+            ReleaseMutex(m_tgsReqMutex);
+        }
+#endif
+    } else if ( ticketinfo.Krb4.btickets ) {
+        ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+        if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+            throw("Unable to lock TGS mutex");
+#endif
+        if ( ProbeKDC() ) {
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            LSH_DLGINFO_EX ldi;
+            ldi.size = sizeof(ldi);
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.title = "Initialize Ticket";
+            ldi.username = NULL;
+            ldi.realm = NULL;
+            ldi.dlgtype = DLGTYPE_PASSWD;
+            ldi.use_defaults = 1;
+
+            pLeash_kinit_dlg_ex(hWnd, &ldi);
+        }
+#ifndef KRB5_TC_NOTICKET
+        else {
+            ReleaseMutex(m_tgsReqMutex);
+        }
+#endif
+    } else {
+        ReleaseMutex(ticketinfo.lockObj);
+        // Do nothing ...
+    }
+    return;
+}
+
+// IP Change Monitoring Functions
+#include <Iphlpapi.h>
+
+
+DWORD
+CLeashApp::GetNumOfIpAddrs(void)
+{
+    PMIB_IPADDRTABLE pIpAddrTable = 0;
+    ULONG            dwSize;
+    DWORD            code;
+    DWORD            index;
+    DWORD            validAddrs = 0;
+
+    dwSize = 0;
+    code = GetIpAddrTable(NULL, &dwSize, 0);
+    if (code == ERROR_INSUFFICIENT_BUFFER) {
+        pIpAddrTable = (PMIB_IPADDRTABLE) malloc(dwSize);
+        code = GetIpAddrTable(pIpAddrTable, &dwSize, 0);
+        if ( code == NO_ERROR ) {
+            for ( index=0; index < pIpAddrTable->dwNumEntries; index++ ) {
+                if (pIpAddrTable->table[index].dwAddr != 0)
+                    validAddrs++;
+            }
+        }
+        free(pIpAddrTable);
+    }
+    return validAddrs;
+}
+
+UINT
+CLeashApp::IpAddrChangeMonitor(void * hWnd)
+{
+    DWORD Result;
+    DWORD prevNumOfAddrs = GetNumOfIpAddrs();
+    DWORD NumOfAddrs;
+
+    if ( !hWnd )
+        return 0;
+
+    while ( TRUE ) {
+        Result = NotifyAddrChange(NULL,NULL);
+        if ( Result != NO_ERROR ) {
+            // We do not have permission to open the device
+            return 0;
+        }
+
+        NumOfAddrs = GetNumOfIpAddrs();
+        if ( NumOfAddrs != prevNumOfAddrs ) {
+            // wait for the network state to stablize
+            Sleep(2000);
+            // this call should probably be mutex protected
+            ObtainTicketsViaUserIfNeeded((HWND)hWnd);
+        }
+        prevNumOfAddrs = NumOfAddrs;
+    }
+
+    return 0;
+}
+
+
+DWORD
+CLeashApp::IpAddrChangeMonitorInit(HWND hWnd)
+{
+    AfxBeginThread(IpAddrChangeMonitor, hWnd);
+    return 0;
+}
+
+UINT
+CLeashApp::InitWorker(void * hWnd)
+{
+#ifndef KRB5_TC_NOTICKET
+    if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock tgsReq");
+#endif
+    if ( ProbeKDC() ) {
+        LSH_DLGINFO_EX ldi;
+        ldi.size = sizeof(ldi);
+        ldi.dlgtype = DLGTYPE_PASSWD;
+        ldi.title = "Initialize Ticket";
+        ldi.username = NULL;
+        ldi.realm = NULL;
+        ldi.use_defaults = 1;
+
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        pLeash_kinit_dlg_ex((HWND)hWnd, &ldi);
+        ::SendMessage((HWND)hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+    }
+#ifndef KRB5_TC_NOTICKET
+    else
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+    return 0;
+}
+
+#ifdef USE_HTMLHELP
+#if _MSC_VER < 1300
+void
+CLeashApp::WinHelp(DWORD dwData, UINT nCmd)
+{
+       switch (nCmd)
+       {
+               case HELP_CONTEXT:
+                       ::HtmlHelp(GetDesktopWindow(), m_helpFile, HH_HELP_CONTEXT, dwData );
+                       break;
+               case HELP_FINDER:
+                       ::HtmlHelp(GetDesktopWindow(), m_helpFile, HH_DISPLAY_TOPIC, 0);
+            break;
+       }
+}
+#endif
+#endif
diff --git a/src/windows/leash/Leash.h b/src/windows/leash/Leash.h
new file mode 100644 (file)
index 0000000..74c9d5d
--- /dev/null
@@ -0,0 +1,156 @@
+//     **************************************************************************************
+//     File:                   Leash.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for Leash.cpp. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_Leash_H__6F45AD91_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
+#define AFX_Leash_H__6F45AD91_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#ifndef __AFXWIN_H__
+       #error include 'stdafx.h' before including this file for PCH
+#endif
+
+// Help
+#define HID_GET_TICKETS_COMMAND                        98312
+#define HID_DESTROY_TICKETS_COMMAND     98313
+#define HID_SYNCHRONIZE_TIME_OPTION     98314
+#define HID_CHANGE_PASSWORD_COMMAND            98315
+#define HID_UPDATE_DISPLAY_COMMAND      98316
+#define HID_DEBUG_WINDOW_OPTION                        98317
+#define HID_LEASH_PROGRAM               98319
+#define HID_ABOUT_KERBEROS              98320
+#define HID_LARGE_ICONS_OPTION          98322
+#define HID_DESTROY_TICKETS_ON_EXIT            98321
+#define HID_UPPERCASE_REALM_OPTION      98323
+#define HID_RESET_WINDOW_OPTION                        98326
+#define HID_AFS_PROPERTIES_COMMAND             98327
+#define HID_KRB4_PROPERTIES_COMMAND            98329
+#define HID_KRB5_PROPERTIES_COMMAND            98330
+#define HID_LEASH_PROPERTIES_COMMAND   98331
+#define HID_LOW_TICKET_ALARM_OPTION            98334
+#define HID_KRBCHECK_OPTION                            98335
+#define HID_KERBEROS_PROPERTIES_COMMAND 98337
+#define HID_HELP_CONTENTS               98340
+#define HID_WHY_USE_LEASH32                            98341
+
+#define HID_ABOUT_LEASH32_COMMAND       123200
+#define HID_EXIT_COMMAND                123201
+#define HID_TOOLBAR_OPTION                             124928
+#define HID_STATUS_BAR_OPTION           124929
+#define HID_LEASH_COMMANDS              131200
+#define HID_ABOUT_LEASH32_MODULES       131225
+#define HID_DEBUG_WINDOW                               131229
+#define HID_KRB4_PROPERTIES_EDIT           131232
+#define HID_KERBEROS_PROPERTIES_EDIT   131233
+#define HID_LEASH_PROPERTIES_EDIT              131239
+#define HID_KRB5_PROPERTIES_FORWARDING  131240
+#define HID_KRB5_PROPERTIES_EDIT           131241
+#define HID_KERBEROS_PROPERTIES_LISTRLM 131250
+#define HID_KERBEROS_PROPERTIES_ADDRLM  131253
+#define HID_KERBEROS_PROPERTIES_EDITRLM 131254
+#define HID_KERBEROS_PROPERTIES_ADDDOM  131255
+#define HID_KERBEROS_PROPERTIES_EDITDOM 131256
+#define HID_KERBEROS_PROPERTIES_ADDHOST 131269
+#define HID_KERBEROS_PROPERTIES_EDITHOST 131271
+#define HID_KERBEROS_PROPERTIES_LISTDOM 131279
+
+#define USE_HTMLHELP
+
+#ifdef USE_HTMLHELP
+#if _MSC_VER >= 1300
+#define CALL_HTMLHELP
+#endif
+#endif
+
+#include "resource.h"       // main symbols
+#include "lglobals.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashApp:
+// See Leash.cpp for the implementation of this class
+//
+
+class CLeashApp : public CWinApp
+{
+private:
+       CString         m_leashDLL;
+       CString         m_krbDLL;
+    CString     m_helpFile;
+       CString         m_msgError;
+
+       BOOL            InitDLLs();
+       BOOL            FirstInstance();
+
+public:
+       static HWND                     m_hProgram;
+       static HINSTANCE        m_hLeashDLL;
+       static HINSTANCE        m_hKrb4DLL;
+       static HINSTANCE        m_hKrb5DLL;
+       static HINSTANCE        m_hKrb5ProfileDLL;
+       static HINSTANCE        m_hAfsDLL;
+       static HINSTANCE        m_hPsapi;
+       static HINSTANCE        m_hToolHelp32;
+       static krb5_context m_krbv5_context;
+       static profile_t    m_krbv5_profile;
+       static HINSTANCE    m_hKrbLSA;
+
+       CLeashApp();
+       virtual ~CLeashApp();
+
+    static BOOL  GetProfileFile(LPSTR confname, UINT szConfname);
+    static BOOL  GetKrb4ConFile(LPSTR confname, UINT szConfname);
+    static BOOL  GetKrb4RealmFile(LPSTR confname, UINT szConfname);
+    static void  ValidateConfigFiles();
+    static void  ObtainTicketsViaUserIfNeeded(HWND hWnd);
+    static DWORD GetNumOfIpAddrs(void);
+    static UINT  IpAddrChangeMonitor(void *);
+           DWORD IpAddrChangeMonitorInit(HWND hWnd);
+    static BOOL  ProbeKDC(void);
+    static UINT  InitWorker(void *);
+
+       // Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashApp)
+       public:
+       virtual BOOL InitInstance();
+#ifdef USE_HTMLHELP
+#if _MSC_VER < 1300
+    virtual void WinHelp(DWORD dwData, UINT nCmd);
+#endif
+#endif
+    //}}AFX_VIRTUAL
+
+    virtual void ParseParam (LPCTSTR lpszParam,BOOL bFlag,BOOL bLast );
+
+  protected:
+// Implementation
+
+       //{{AFX_MSG(CLeashApp)
+    //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+extern CLeashApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+
+
+#endif // !defined(AFX_Leash_H__6F45AD91_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/Leash.rc b/src/windows/leash/Leash.rc
new file mode 100644 (file)
index 0000000..9594446
--- /dev/null
@@ -0,0 +1,999 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif\r\n"
+    "#include ""res\\Leash.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME           ICON                    "res\\Leash.ico"
+IDR_LeashTYPE           ICON                    "res\\Leash_Doc.ico"
+IDI_LEASH_PRINCIPAL_GOOD ICON                    "res\\Leash_user_green.ico"
+IDI_LEASH_PRINCIPAL_LOW ICON                    "res\\Leash_user_orange.ico"
+IDI_LEASH_PRINCIPAL_EXPIRED ICON                    "res\\Leash_user_red.ico"
+IDI_LEASH_PRINCIPAL_NONE ICON                    "res\\Leash_user_out.ico"
+IDI_LEASH               ICON                    "res\\Leash.ico"
+IDI_TICKETTYPE_GOOD     ICON                    "res\\Leash_tickets_green.ico"
+IDI_TICKETTYPE_LOW      ICON                    "res\\Leash_tickets_orange.ico"
+IDI_TICKETTYPE_EXPIRED  ICON                    "res\\Leash_tickets_red.ico"
+IDI_TICKETTYPE_NOTINSTALLED ICON                    "res\\Leash_tickets_out.ico"
+IDI_TICKET_GOOD         ICON                    "res\\Leash_tkt_green.ico"
+IDI_TICKET_LOW          ICON                    "res\\Leash_tkt_orange.ico"
+IDI_TICKET_EXPIRED      ICON                    "res\\Leash_tkt_red.ico"
+IDI_LEASH_TRAY_GOOD     ICON                    "res\\doghead_green.ico"
+IDI_LEASH_TRAY_LOW      ICON                    "res\\doghead_orange.ico"
+IDI_LEASH_TRAY_EXPIRED  ICON                    "res\\doghead_red.ico"
+IDI_LEASH_TRAY_NONE     ICON                    "res\\doghead_grey.ico"
+IDI_LEASH_TICKET_ADDRESS ICON                    "res\\address.ico"
+IDI_LEASH_TICKET_SESSION ICON                    "res\\key.ico"
+IDI_LEASH_TICKET_ENCRYPTION ICON                    "res\\encryption.ico"
+IDI_TOOLBAR_INIT        ICON                    "res\\new.ico"
+IDI_TOOLBAR_RENEW       ICON                    "res\\renew.ico"
+IDI_TOOLBAR_IMPORT      ICON                    "res\\import.ico"
+IDI_TOOLBAR_DESTROY     ICON                    "res\\destroy.ico"
+IDI_TOOLBAR_PASSWORD    ICON                    "res\\password.ico"
+IDI_TOOLBAR_REFRESH     ICON                    "res\\refresh.ico"
+IDI_TOOLBAR_SYNC        ICON                    "res\\sync.ico"
+IDI_TOOLBAR_INIT_DISABLED ICON                    "res\\new_disabled.ico"
+IDI_TOOLBAR_RENEW_DISABLED ICON                    "res\\renew_disabled.ico"
+IDI_TOOLBAR_IMPORT_DISABLED ICON                    "res\\import_disabled.ico"
+IDI_TOOLBAR_DESTROY_DISABLED ICON                    "res\\destroy_disabled.ico"
+IDI_TOOLBAR_PASSWORD_DISABLED ICON                    "res\\password_disabled.ico"
+IDI_TOOLBAR_REFRESH_DISABLED ICON                    "res\\refresh_disabled.ico"
+IDI_TOOLBAR_SYNC_DISABLED ICON                    "res\\sync_disabled.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MAINFRAME MENU
+BEGIN
+    POPUP "&File"
+    BEGIN
+        MENUITEM "E&xit",                       ID_APP_EXIT
+    END
+    POPUP "&Action"
+    BEGIN
+        MENUITEM "&Gew Ticket(s)/Token(s)\tCtrl+T", ID_INIT_TICKET
+        MENUITEM "&Renew Ticket(s)/Token(s)\tCtrl+R", ID_RENEW_TICKET
+        MENUITEM "&Import Ticket(s)/Token(s)\tCtrl+I", ID_IMPORT_TICKET
+        MENUITEM "&Destroy Ticket(s)/Token(s)\tCtrl+D", ID_DESTROY_TICKET
+        MENUITEM SEPARATOR
+        MENUITEM "&Change Password...",         ID_CHANGE_PASSWORD
+        MENUITEM SEPARATOR
+        MENUITEM "&Reset Window Size/Pos",      ID_RESET_WINDOW_SIZE
+        MENUITEM "&Synchronize Time",           ID_SYN_TIME
+        MENUITEM "&Update Display\tF5",         ID_UPDATE_DISPLAY
+    END
+    POPUP "&View"
+    BEGIN
+        MENUITEM "&Large Icons",                ID_LARGE_ICONS
+        MENUITEM "&Toolbar",                    ID_VIEW_TOOLBAR
+        MENUITEM "&Status Bar",                 ID_VIEW_STATUS_BAR
+        MENUITEM "&Debug Window",               ID_DEBUG_MODE
+    END
+    POPUP "&Options"
+    BEGIN
+        MENUITEM "Upper &Case Realm Name",      ID_UPPERCASE_REALM
+        MENUITEM "&Automatic Ticket Renewal",   ID_AUTO_RENEW
+        MENUITEM "&Expiration Alarm",           ID_LOW_TICKET_ALARM
+        MENUITEM "&Destroy Tickets/Tokens on Exit", ID_KILL_TIX_ONEXIT
+        MENUITEM SEPARATOR
+        MENUITEM "&Leash Properties...\tCtrl+L", ID_LEASH_PROPERTIES
+        MENUITEM "&Kerberos Properties...\tCtrl+K", ID_PROPERTIES
+        MENUITEM "Kerberos v&4 Properties...\tCtrl+4", ID_KRB4_PROPERTIES
+        MENUITEM "Kerberos v&5 Properties...\tCtrl+5", ID_KRB5_PROPERTIES
+        MENUITEM "&AFS Properties\tCtrl+A",     ID_AFS_CONTROL_PANEL
+    END
+    POPUP "&Help"
+    BEGIN
+        MENUITEM "Why Use Leash",               ID_HELP_WHYUSELEASH32
+        MENUITEM "About &Kerberos ",            ID_HELP_KERBEROS_
+        MENUITEM SEPARATOR
+        MENUITEM "&Contents",                   ID_HELP_LEASH32
+        MENUITEM "&Index",                      ID_HELP_LEASH_
+        MENUITEM SEPARATOR
+        MENUITEM "&About Leash",                ID_APP_ABOUT
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDR_MAINFRAME ACCELERATORS
+BEGIN
+    "4",            ID_KRB4_PROPERTIES,     VIRTKEY, CONTROL, NOINVERT
+    "5",            ID_KRB5_PROPERTIES,     VIRTKEY, CONTROL, NOINVERT
+    "A",            ID_AFS_CONTROL_PANEL,   VIRTKEY, CONTROL, NOINVERT
+    "C",            ID_EDIT_COPY,           VIRTKEY, CONTROL, NOINVERT
+    "D",            ID_DESTROY_TICKET,      VIRTKEY, CONTROL, NOINVERT
+    "I",            ID_IMPORT_TICKET,       VIRTKEY, CONTROL, NOINVERT
+    "K",            ID_PROPERTIES,          VIRTKEY, CONTROL, NOINVERT
+    "L",            ID_LEASH_PROPERTIES,    VIRTKEY, CONTROL, NOINVERT
+    "N",            ID_FILE_NEW,            VIRTKEY, CONTROL, NOINVERT
+    "O",            ID_FILE_OPEN,           VIRTKEY, CONTROL, NOINVERT
+    "R",            ID_RENEW_TICKET,        VIRTKEY, CONTROL, NOINVERT
+    "S",            ID_FILE_SAVE,           VIRTKEY, CONTROL, NOINVERT
+    "T",            ID_INIT_TICKET,         VIRTKEY, CONTROL, NOINVERT
+    "V",            ID_EDIT_PASTE,          VIRTKEY, CONTROL, NOINVERT
+    VK_BACK,        ID_EDIT_UNDO,           VIRTKEY, ALT, NOINVERT
+    VK_DELETE,      ID_BUTTON_REALM_REMOVE, VIRTKEY, NOINVERT
+    VK_DELETE,      ID_EDIT_CUT,            VIRTKEY, SHIFT, NOINVERT
+    VK_F1,          ID_HELP,                VIRTKEY, NOINVERT
+    VK_F1,          ID_CONTEXT_HELP,        VIRTKEY, SHIFT, NOINVERT
+    VK_F5,          ID_UPDATE_DISPLAY,      VIRTKEY, NOINVERT
+    VK_F6,          ID_NEXT_PANE,           VIRTKEY, NOINVERT
+    VK_F6,          ID_PREV_PANE,           VIRTKEY, SHIFT, NOINVERT
+    VK_INSERT,      ID_EDIT_COPY,           VIRTKEY, CONTROL, NOINVERT
+    VK_INSERT,      ID_EDIT_PASTE,          VIRTKEY, SHIFT, NOINVERT
+    "X",            ID_EDIT_CUT,            VIRTKEY, CONTROL, NOINVERT
+    "Z",            ID_EDIT_UNDO,           VIRTKEY, CONTROL, NOINVERT
+END
+
+IDD_KRB4_DOMAINREALM_MAINT ACCELERATORS
+BEGIN
+    "F",            ID_BUTTON_HOSTNAME_REMOVE, VIRTKEY, CONTROL, NOINVERT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_FRAMEOWNER DIALOG  0, 0, 219, 49
+STYLE DS_SETFONT | WS_POPUP
+FONT 8, "MS Sans Serif"
+BEGIN
+END
+
+IDD_LEASH_FORMVIEW DIALOG  0, 0, 219, 49
+STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Tree1",IDC_TREEVIEW,"SysTreeView32",TVS_HASBUTTONS |
+                    TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP |
+                    WS_TABSTOP | 0x800,0,19,164,13
+    LTEXT           "Your Kerberos Tickets and AFS Tokens (Issued/Expires/[Renew]/Principal)",
+                    IDC_LABEL_KERB_TICKETS,6,5,280,12
+END
+
+IDD_LEASH_ABOUTBOX DIALOG  0, 0, 310, 146
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About Leash"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Leash Modules",IDC_LEASH_MODULES,"Button",
+                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,127,64,10
+    CONTROL         "Missing Modules",IDC_NOT_LOADED_MODULES,"Button",
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,77,127,68,10
+    CONTROL         "All Modules",IDC_ALL_MODULES,"Button",
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,148,127,52,10
+    PUSHBUTTON      "&Properties",IDC_PROPERTIES,209,125,56,14
+    DEFPUSHBUTTON   "&OK",IDOK,268,125,35,14
+    LISTBOX         IDC_LEASH_MODULE_LB,7,50,296,62,LBS_SORT |
+                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
+                    WS_TABSTOP
+    ICON            IDR_MAINFRAME,IDC_STATIC_ABOUTBOX_LEASH,11,9,20,20
+    LTEXT           "Modules Loaded:",IDC_STATIC_MODULES_LOADED,8,40,56,8
+    LTEXT           "3",IDC_STATIC_NO_OF_MODULES,67,40,8,8
+    EDITTEXT        IDC_ABOUT_COPYRIGHT,40,19,263,11,ES_AUTOHSCROLL |
+                    ES_READONLY | NOT WS_BORDER | WS_GROUP | NOT WS_TABSTOP
+    EDITTEXT        IDC_ABOUT_VERSION,40,8,263,11,ES_AUTOHSCROLL |
+                    ES_READONLY | NOT WS_BORDER | WS_GROUP | NOT WS_TABSTOP
+END
+
+IDD_LEASH_DEBUG_WINDOW DIALOG  200, 200, 338, 197
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+    WS_SYSMENU
+CAPTION "Leash Debug Window"
+FONT 8, "MS Sans Serif"
+BEGIN
+    PUSHBUTTON      "Copy &All To Clipboard",IDC_COPY_TO_CLIPBOARD,181,179,
+                    96,14
+    LISTBOX         IDC_DEBUG_LISTBOX,7,7,324,162,LBS_NOINTEGRALHEIGHT |
+                    WS_VSCROLL | WS_TABSTOP
+    PUSHBUTTON      "&Cancel",IDCANCEL,281,179,50,14
+    LTEXT           "Log File Location:",IDC_LOG_FILE_LOCATION_LABEL,10,182,
+                    57,8
+    LTEXT           "C:\\TEMP\\",IDC_LOG_FILE_LOCATION_TEXT,68,182,105,8
+END
+
+IDD_LEASH_MESSAGE_BOX DIALOG  0, 0, 257, 60
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP |
+    WS_CAPTION
+CAPTION "Leash Warning"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,104,42,50,14
+    CTEXT           "Leash Warning Here!!!",IDC_LEASH_WARNING_MSG,0,7,257,27
+END
+
+IDD_KRB4_PROP_LOCATION DIALOG  0, 0, 316, 191
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Client File Location"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_TICKET_FILE,64,24,239,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_KRB_LOC,64,110,203,12,ES_AUTOHSCROLL | WS_GROUP
+    PUSHBUTTON      "Browse",IDC_BUTTON_KRB_BROWSE,271,109,31,14,WS_GROUP
+    PUSHBUTTON      "Browse",IDC_BUTTON_KRBREALM_BROWSE,271,129,32,14,
+                    WS_GROUP
+    LTEXT           "Name:",IDC_STATIC_TICKET_FILEPATH,34,25,22,8
+    GROUPBOX        "Configuration File(s) Path",IDC_STATIC_CONFIG_FILES,7,
+                    92,301,93
+    GROUPBOX        "Ticket File",IDC_STATIC_TICKETFILE,7,8,301,71
+    LTEXT           "Config.:",IDC_STATIC_KRBCON,31,110,25,8
+    LTEXT           "Ticket file name is set in your computer's environment!\nTo edit, remove it from the environment.",
+                    IDC_STATIC_TXT,12,54,283,19
+    LTEXT           "One or more Configuration file locations are set in your computer's environment!\nTo edit, remove all of them from the environment.",
+                    IDC_STATIC_CONFILES,12,160,284,19
+    EDITTEXT        IDC_EDIT_KRBREALM_LOC,64,130,203,12,ES_AUTOHSCROLL |
+                    WS_GROUP
+    LTEXT           "Realms:",IDC_STATIC_KRBREALMS,30,130,26,8
+END
+
+IDD_KRB_PROP_CONTENT DIALOG  0, 0, 314, 172
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Default Realm Configuration"
+FONT 8, "MS Sans Serif"
+BEGIN
+    COMBOBOX        IDC_EDIT_DEFAULT_REALM,12,28,289,84,CBS_DROPDOWNLIST |
+                    CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    EDITTEXT        IDC_EDIT_REALM_HOSTNAME,12,57,289,12,ES_AUTOHSCROLL |
+                    ES_READONLY | NOT WS_TABSTOP
+    LTEXT           "Your Kerberos Realm:",IDC_STATIC_DEFAULT_REALM,12,17,70,
+                    8
+    GROUPBOX        "Kerberos Realm/Host Server",IDC_STATIC_KRB,7,3,300,77
+    GROUPBOX        "Computer Host/Domain Name",IDC_STATIC_KRBREALM,7,89,300,
+                    75
+    LTEXT           "Your Computer's Host Name",IDC_STATIC_HOST,12,101,90,8
+    LTEXT           "Your Computer's Domain Name:",IDC_STATIC_DOMAIN,12,129,
+                    101,8
+    EDITTEXT        IDC_EDIT_HOSTNAME,12,112,289,12,ES_AUTOHSCROLL |
+                    ES_READONLY | NOT WS_TABSTOP
+    EDITTEXT        IDC_EDIT_DOMAINNAME,12,140,289,12,ES_AUTOHSCROLL |
+                    ES_READONLY | NOT WS_TABSTOP
+    LTEXT           "Your Kerberos Server:",IDC_STATIC_REALM_HOSTNAME,12,46,
+                    70,8
+END
+
+IDD_LEASH_FILESPECIAL DIALOG  0, 0, 241, 112
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
+FONT 8, "MS Sans Serif"
+BEGIN
+    GROUPBOX        "",stc32,7,7,227,98,NOT WS_VISIBLE
+END
+
+IDD_LEASH_PROPERTIES DIALOGEX 0, 0, 305, 166
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Leash Properties"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+    EDITTEXT        IDC_EDIT_TIME_SERVER,59,22,233,12,ES_AUTOHSCROLL
+    PUSHBUTTON      "&Help",IDC_BUTTON_LEASHINI_HELP2,138,145,50,14
+    DEFPUSHBUTTON   "&OK",IDOK,242,145,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,190,145,50,14
+    LTEXT           "Name:",IDC_STATIC_TIMESERVER,31,23,22,8
+    GROUPBOX        "Time Server",IDC_STATIC_OPTIONS,7,7,291,45
+    LTEXT           "Time server name is set in your computer's environment!\nTo edit, remove it from the environment.",
+                    IDC_STATIC_TIMEHOST,31,22,201,21
+    CONTROL         "Create Configuration Files &Missing at Startup",
+                    IDC_CHECK_CREATE_MISSING_CFG,"Button",BS_AUTOCHECKBOX |
+                    WS_TABSTOP,15,105,244,10
+    PUSHBUTTON      "&Restore Leash Defaults",IDC_RESET_DEFAULTS,31,126,243,
+                    14
+    GROUPBOX        "Miscellaneous Options",IDC_GROUP_LEASH_MISC,7,95,291,29
+    GROUPBOX        "Automatic MSLSA Ticket Importation",IDC_STATIC,7,52,291,
+                    40
+    CONTROL         "Never",IDC_RADIO_MSLSA_IMPORT_OFF,"Button",
+                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,70,35,10
+    CONTROL         "Always",IDC_RADIO_MSLSA_IMPORT_ON,"Button",
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,62,70,48,10
+    CONTROL         "When MSLSA Principal matches Default Realm",
+                    IDC_RADIO_MSLSA_IMPORT_MATCH,"Button",BS_AUTORADIOBUTTON |
+                    WS_TABSTOP,116,71,165,10
+END
+
+IDD_KRB5_PROP_CONTENT DIALOG  0, 0, 321, 126
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Configuration Options"
+FONT 8, "MS Sans Serif"
+BEGIN
+    GROUPBOX        "Ticket Options",IDC_STATIC_TICKET_OPTIONS,7,7,307,41
+    CONTROL         "&Forwardable",IDC_CHECK_FORWARDABLE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,18,23,55,10
+    CONTROL         "&Proxiable",IDC_CHECK_PROXIABLE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,94,23,45,10
+    CONTROL         "&Renewable",IDC_CHECK_RENEWABLE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,160,23,52,10
+    CONTROL         "No &Addresses",IDC_CHECK_NO_ADDRESS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,233,23,60,10
+END
+
+IDD_KRB5_PROP_LOCATION DIALOG  0, 0, 321, 173
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "File Location"
+FONT 8, "MS Sans Serif"
+BEGIN
+    GROUPBOX        "&Ticket File",IDC_STATIC__KRB5_TICKETFILE,7,8,307,67
+    EDITTEXT        IDC_EDIT_KRB5_TXT_FILE,17,21,291,12,ES_AUTOHSCROLL
+    LTEXT           "Ticket file name is set in your computer's environment!\nTo edit, remove it from the environment.",
+                    IDC_STATIC_TICKETFILE,12,51,284,19
+    GROUPBOX        "&Configuration File",IDC_STATIC_TICKET_FILE,7,86,307,80
+    EDITTEXT        IDC_EDIT_KRB5INI_LOCATION,17,100,237,12,ES_AUTOHSCROLL |
+                    WS_GROUP
+    PUSHBUTTON      "&Browse",IDC_BUTTON_KRB5INI_BROWSE,259,99,50,14,
+                    WS_GROUP
+    CONTROL         "Confirm that new configuration file &exists.",
+                    IDC_CHECK_CONFIRM_KRB5_EXISTS,"Button",BS_AUTOCHECKBOX |
+                    WS_TABSTOP,12,123,143,10
+    LTEXT           "Configuration file location is set in your computer's environment!\nTo edit, remove it from the environment.",
+                    IDC_STATIC_INIFILES,12,142,284,19
+END
+
+IDD_KRB_REALMHOST_MAINT DIALOG  0, 0, 316, 213
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Realm / Server Mapping"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "In&sert",IDC_BUTTON_REALM_HOST_ADD,27,190,34,14
+    PUSHBUTTON      "&Remove",ID_BUTTON_REALM_REMOVE,64,190,34,14
+    PUSHBUTTON      "Re&name",IDC_BUTTON_REALM_EDIT,102,190,34,14
+    LISTBOX         IDC_LIST_KDC_REALM,7,21,146,160,LBS_SORT |
+                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+    LISTBOX         IDC_LIST_KDC_HOST,163,21,146,78,LBS_NOINTEGRALHEIGHT |
+                    WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+    LTEXT           "Kerberos Realms",IDC_STATIC_REALM,8,11,54,8
+    LTEXT           "Servers Hosting a KDC",IDC_STATIC,163,11,74,8
+    PUSHBUTTON      "&Make Admin",IDC_BUTTON_ADMINSERVER,176,106,55,14,
+                    WS_DISABLED
+    DEFPUSHBUTTON   "Inser&t",IDC_BUTTON_KDCHOST_ADD,183,127,34,14
+    PUSHBUTTON      "Rem&ove",IDC_BUTTON_KDCHOST_REMOVE,220,127,34,14
+    PUSHBUTTON      "Ed&it",IDC_BUTTON_KDCHOST_EDIT,257,126,34,14
+    PUSHBUTTON      "R&emove Admin",IDC_BUTTON_REMOVE_ADMINSERVER,242,106,55,
+                    14,WS_DISABLED
+    CONTROL         "Use DNS KDC Lookup",IDC_DNS_KDC,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,169,158,131,10
+END
+
+IDD_KRB4_DOMAINREALM_MAINT DIALOG  0, 0, 313, 213
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Domain-Host/Realm Maintenance"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LISTBOX         IDC_LIST_DOMAINREALM,7,7,299,174,LBS_NOINTEGRALHEIGHT |
+                    WS_VSCROLL | WS_TABSTOP
+    DEFPUSHBUTTON   "&Add",IDC_BUTTON_REALM_HOST_ADD,52,192,50,14
+    PUSHBUTTON      "&Remove",ID_BUTTON_REALM_HOST_REMOVE,106,192,50,14
+    PUSHBUTTON      "&Edit",IDC_BUTTON_REALM_HOST_EDIT,160,192,50,14
+    PUSHBUTTON      "&Help",IDC_BUTTON_HOSTMAINT_HELP,214,192,50,14
+END
+
+IDD_KRB_ADD_REALM DIALOG  0, 0, 295, 94
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Add a Kerberos Realm"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_REALM,70,39,213,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    PUSHBUTTON      "&OK",IDOK,232,67,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,179,67,50,14
+    LTEXT           "Kerberos Realm:",IDC_STATIC_REALM_HOSTNAME,12,41,53,8
+    LTEXT           "NOTE: You are about to add a Realm to the ""Kerberos Realm"" Listbox!!!",
+                    IDC_STATIC_NOTE,11,15,271,8
+END
+
+IDD_KRB_EDIT_REALM DIALOG  0, 0, 295, 94
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit Kerberos Realm"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_REALM,70,39,213,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    PUSHBUTTON      "&OK",IDOK,231,67,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,179,67,50,14
+    LTEXT           "Kerberos Realm:",IDC_STATIC_DEFAULT_REALM,12,41,53,8
+    LTEXT           "NOTE: You are about to edit a Realm to the ""Kerberos Realm"" Listbox!!!",
+                    IDC_STATIC_NOTE,11,15,267,8
+END
+
+IDD_KRB4_ADD_DOMAINREALMNAME DIALOG  0, 0, 295, 89
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Add Your Domain-Host/Kerberos Realm Names to List"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_DOMAINHOSTNAME,75,15,208,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_DOMAINREALMNAME,75,32,208,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    PUSHBUTTON      "&OK",IDOK,232,62,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,179,62,50,14
+    LTEXT           "Domain or Host: ",IDC_STATIC_DEFAULT_REALM,12,17,58,8
+    LTEXT           "Kerberos Realm:",IDC_STATIC_REALM_HOSTNAME,17,34,53,8
+END
+
+IDD_KRB4_EDIT_DOMAINREALMNAME DIALOG  0, 0, 295, 89
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit Your Domain-Host/Kerberos Realm Names to List"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_DOMAINHOST,75,15,208,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_REALMNAME,75,32,208,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    PUSHBUTTON      "&OK",IDOK,232,62,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,179,62,50,14
+    LTEXT           "Domain or Host: ",IDC_STATIC_DEFAULT_REALM,12,17,58,8
+    LTEXT           "Kerberos Realm:",IDC_STATIC_REALM_HOSTNAME,17,34,53,8
+END
+
+IDD_KRB_ADD_KDC_HOSTSERVER DIALOG  0, 0, 295, 94
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Add a Kerberos Host Server"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_KDC_HOST,70,39,213,12,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "OK",IDOK,231,67,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,179,67,50,14
+    LTEXT           "Kerberos Server:",IDC_STATIC_DEFAULT_REALM,11,41,54,8
+    LTEXT           "NOTE: You are about to add a Server to the"" Server Hosting a KDC"" Listbox!!! ",
+                    IDC_STATIC_NOTE,11,15,267,8
+END
+
+IDD_KRB_EDIT_KDC_HOSTSERVER DIALOG  0, 0, 295, 94
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit a Kerberos Server"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_KDC_HOST,70,39,213,12,ES_AUTOHSCROLL
+    PUSHBUTTON      "&OK",IDOK,231,67,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,180,67,50,14
+    LTEXT           "Kerberos Server:",IDC_STATIC_REALM,11,41,54,8
+    LTEXT           "NOTE: You are about to edit a Server to the"" Server Hosting a KDC"" Listbox!!! ",
+                    IDC_STATIC_NOTE,11,15,267,8
+END
+
+IDD_KRB4_REALMHOST_MAINT2 DIALOG  0, 0, 313, 214
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Realm/Host Maintenance"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "&Add",IDC_BUTTON_KRB4_REALM_HOST_ADD,53,161,50,14
+    PUSHBUTTON      "&Remove",ID_BUTTON_KRB4_REALM_HOST_REMOVE,107,161,50,14
+    PUSHBUTTON      "&Edit",IDC_BUTTON_KRB4_REALM_HOST_EDIT,161,161,50,14
+    PUSHBUTTON      "&Help",IDC_BUTTON_REALMHOST_MAINT_HELP2,214,161,50,14
+    LISTBOX         IDC_LIST_REMOVE_HOST,7,7,299,149,LBS_NOINTEGRALHEIGHT |
+                    WS_VSCROLL | WS_TABSTOP
+    CONTROL         "Use DNS KDC Lookup",IDC_KRB4_DNS_KDC,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,18,186,89,10
+END
+
+IDD_KRB4_EDIT_REALM DIALOG  0, 0, 296, 113
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit Kerberos Realm/Kerberos Host Names"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_DEFAULT_REALM,70,23,213,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_REALM_HOSTNAME,70,41,213,12,ES_AUTOHSCROLL
+    CONTROL         "Has Administrative Server",IDC_RADIO_ADMIN_SERVER,
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,50,61,96,12
+    CONTROL         "No Administrative Server",IDC_RADIO_NO_ADMIN_SERVER,
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,154,61,92,12
+    PUSHBUTTON      "&OK",IDOK,233,86,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,181,86,50,14
+    LTEXT           "Kerberos Realm:",IDC_STATIC_DEFAULT_REALM,11,25,53,8
+    LTEXT           "Kerberos Host:",IDC_STATIC_REALM_HOSTNAME,16,43,48,8
+END
+
+IDD_KRB4_ADD_REALM DIALOG  0, 0, 296, 113
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Add Kerberos Realm/Kerberos Host Names"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_DEFAULT_REALM,70,23,213,12,ES_UPPERCASE |
+                    ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_REALM_HOSTNAME,70,41,213,12,ES_AUTOHSCROLL
+    CONTROL         "Has Administrative Server",IDC_RADIO_ADMIN_SERVER,
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,50,61,95,12
+    CONTROL         "No Administrative Server",IDC_RADIO_NO_ADMIN_SERVER,
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,154,61,92,12
+    PUSHBUTTON      "&OK",IDOK,232,86,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,179,86,50,14
+    LTEXT           "Kerberos Realm:",IDC_STATIC_DEFAULT_REALM,11,25,53,8
+    LTEXT           "Kerberos Host:",IDC_STATIC_REALM_HOSTNAME,16,43,48,8
+END
+
+IDD_KRB_DOMAINREALM_MAINT DIALOG  0, 0, 314, 213
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "DNS / Realm Mapping"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LISTBOX         IDC_LIST_DOMAINREALM,7,7,299,174,LBS_SORT |
+                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+    DEFPUSHBUTTON   "&Insert",IDC_BUTTON_HOST_ADD,77,192,50,14
+    PUSHBUTTON      "&Remove",ID_BUTTON_HOST_REMOVE,131,192,50,14
+    PUSHBUTTON      "&Edit",IDC_BUTTON_HOST_EDIT,185,192,50,14
+END
+
+IDD_AFS_PROPERTIES DIALOG  0, 0, 290, 68
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "AFS Properties"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "AFS Enabled",IDC_RADIO_AFS_ENABLED,"Button",
+                    BS_AUTORADIOBUTTON,12,19,59,10
+    CONTROL         "AFS Disabled",IDC_RADIO_AFS_DISABLED,"Button",
+                    BS_AUTORADIOBUTTON,80,19,59,10
+    PUSHBUTTON      "AFS Properties",IDC_BUTTON_AFS_PROPERTIES,11,47,70,14
+    DEFPUSHBUTTON   "&OK",IDOK,227,47,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,173,47,50,14
+    PUSHBUTTON      "&Help",IDC_BUTTON_LEASHINI_HELP2,119,47,50,14
+END
+
+IDD_KRB_PROP_MISC DIALOGEX 0, 0, 314, 215
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Ticket Lifetime and Other Initialization Options"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+    GROUPBOX        "Default Ticket Lifetime",
+                    IDC_STATIC_KRB_DEFAULT_LIFETIME,7,7,147,39
+    GROUPBOX        "Ticket Lifetime Range",IDC_STATIC_LIFETIME_RANGE,7,47,
+                    148,97
+    GROUPBOX        "Ticket Renew Till Range",IDC_STATIC_RENEW_TILL_RANGE,
+                    155,47,152,97
+    EDITTEXT        IDC_EDIT_LIFETIME_D,21,23,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFETIME_H,59,23,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFETIME_M,97,23,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MIN_D,23,77,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MIN_H,59,77,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MIN_M,98,77,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MAX_D,23,109,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MAX_H,59,109,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_LIFE_MAX_M,99,109,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    GROUPBOX        "Minimum Lifetime",IDC_STATIC_LIFE_RANGE_MIN,16,64,132,
+                    32
+    GROUPBOX        "Maximum Lifetime",IDC_STATIC,16,99,132,30
+    GROUPBOX        "Minimum Renewable Lifetime",IDC_STATIC,161,64,136,31
+    GROUPBOX        "Maximum Renewable Lifetime",IDC_STATIC,162,98,136,31
+    EDITTEXT        IDC_EDIT_RENEWTILL_D,168,23,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEWTILL_H,206,23,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEWTILL_M,244,23,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MIN_D,168,77,25,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MIN_H,207,77,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MIN_M,245,77,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MAX_D,168,109,26,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MAX_H,208,109,21,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_RENEW_MAX_M,246,109,20,14,ES_RIGHT |
+                    ES_AUTOHSCROLL | ES_NUMBER
+    LTEXT           "d",IDC_STATIC,46,80,8,8
+    LTEXT           "h",IDC_STATIC,82,79,8,8
+    LTEXT           "m",IDC_STATIC,121,80,8,8
+    LTEXT           "d",IDC_STATIC,45,112,8,8
+    LTEXT           "h",IDC_STATIC,81,112,8,8
+    LTEXT           "m",IDC_STATIC,123,112,8,8
+    LTEXT           "d",IDC_STATIC,194,80,8,8
+    LTEXT           "h",IDC_STATIC,229,80,8,8
+    LTEXT           "m",IDC_STATIC,267,80,8,8
+    LTEXT           "d",IDC_STATIC,194,112,8,8
+    LTEXT           "h",IDC_STATIC,230,112,8,8
+    LTEXT           "m",IDC_STATIC,267,112,8,8
+    LTEXT           "d",IDC_STATIC,45,26,8,8
+    LTEXT           "h",IDC_STATIC,83,26,8,8
+    LTEXT           "m",IDC_STATIC,120,26,8,8
+    GROUPBOX        "Default Ticket Renewable Lifetime",
+                    IDC_STATIC_KRB_DEFAULT_RENEWTILL,155,7,151,39
+    LTEXT           "d",IDC_STATIC,192,26,8,8
+    LTEXT           "h",IDC_STATIC,230,26,8,8
+    LTEXT           "m",IDC_STATIC,267,26,8,8
+    GROUPBOX        "Ticket Initialization Options",IDC_STATIC,7,151,300,59
+    CONTROL         "Request Kerberos 4 Tickets",IDC_CHECK_REQUEST_KRB4,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,167,203,10
+    CONTROL         "Preserve Ticket Initialization Dialog Options",
+                    IDC_CHECK_PRESERVE_KINIT_OPTIONS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,20,182,208,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+    IDD_LEASH_FORMVIEW, DIALOG
+    BEGIN
+        RIGHTMARGIN, 217
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 42
+    END
+
+    IDD_LEASH_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 303
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 139
+    END
+
+    IDD_LEASH_DEBUG_WINDOW, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 331
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 190
+    END
+
+    IDD_KRB4_PROP_LOCATION, DIALOG
+    BEGIN
+        LEFTMARGIN, 6
+        RIGHTMARGIN, 307
+        TOPMARGIN, 6
+        BOTTOMMARGIN, 184
+    END
+
+    IDD_KRB_PROP_CONTENT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 307
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 164
+    END
+
+    IDD_LEASH_FILESPECIAL, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 234
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 105
+    END
+
+    IDD_LEASH_PROPERTIES, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 298
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 159
+    END
+
+    IDD_KRB5_PROP_CONTENT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 314
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 55
+        HORZGUIDE, 48
+    END
+
+    IDD_KRB5_PROP_LOCATION, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 314
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 166
+    END
+
+    IDD_KRB_REALMHOST_MAINT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 309
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 206
+    END
+
+    IDD_KRB4_DOMAINREALM_MAINT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 306
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 206
+    END
+
+    IDD_KRB_ADD_REALM, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 87
+    END
+
+    IDD_KRB_EDIT_REALM, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 87
+    END
+
+    IDD_KRB4_ADD_DOMAINREALMNAME, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 82
+    END
+
+    IDD_KRB4_EDIT_DOMAINREALMNAME, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 82
+    END
+
+    IDD_KRB_ADD_KDC_HOSTSERVER, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 87
+    END
+
+    IDD_KRB_EDIT_KDC_HOSTSERVER, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 288
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 87
+    END
+
+    IDD_KRB4_REALMHOST_MAINT2, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 306
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 206
+    END
+
+    IDD_KRB4_EDIT_REALM, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 289
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 106
+    END
+
+    IDD_KRB4_ADD_REALM, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 289
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 106
+    END
+
+    IDD_KRB_DOMAINREALM_MAINT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 307
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 206
+    END
+
+    IDD_AFS_PROPERTIES, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 283
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 61
+    END
+
+    IDD_KRB_PROP_MISC, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 307
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 210
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Toolbar
+//
+
+IDR_MAINFRAME TOOLBAR  18, 18
+BEGIN
+    BUTTON      ID_INIT_TICKET
+    BUTTON      ID_RENEW_TICKET
+    BUTTON      ID_IMPORT_TICKET
+    BUTTON      ID_DESTROY_TICKET
+    SEPARATOR
+    BUTTON      ID_CHANGE_PASSWORD
+    SEPARATOR
+    BUTTON      ID_UPDATE_DISPLAY
+    BUTTON      ID_SYN_TIME
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDR_MAINFRAME           BITMAP                  "res\\Leash_toolbar.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+    IDR_MAINFRAME           "Leash32\n\nLeash32\n\n\nLeash32.Document\nLeash32 Document"
+END
+
+STRINGTABLE
+BEGIN
+    AFX_IDS_APP_TITLE       "Leash"
+    AFX_IDS_IDLEMESSAGE     "For Help, press F1"
+    AFX_IDS_HELPMODEMESSAGE "Select an object on which to get Help"
+END
+
+STRINGTABLE
+BEGIN
+    ID_VIEW_TOOLBAR         "Show or hide the toolbar\nToggle ToolBar"
+    ID_VIEW_STATUS_BAR      "Show or hide the status bar\nToggle StatusBar"
+END
+
+STRINGTABLE
+BEGIN
+    AFX_IDS_SCSIZE          "Change the window size"
+    AFX_IDS_SCMOVE          "Change the window position"
+    AFX_IDS_SCMINIMIZE      "Reduce the window to an icon"
+    AFX_IDS_SCMAXIMIZE      "Enlarge the window to full size"
+    AFX_IDS_SCNEXTWINDOW    "Switch to the next document window"
+    AFX_IDS_SCPREVWINDOW    "Switch to the previous document window"
+    AFX_IDS_SCCLOSE         "Close the active window and prompts to save the documents"
+END
+
+STRINGTABLE
+BEGIN
+    AFX_IDS_SCRESTORE       "Restore the window to normal size"
+    AFX_IDS_SCTASKLIST      "Activate Task List"
+END
+
+STRINGTABLE
+BEGIN
+    ID_PROPERTIES           "Enables you to change settings"
+    ID_IMPORT_TICKET        "Convert MS Windows credentials into tickets/tokens\n Import Ticket(s) "
+    ID_INIT_TICKET          "Activate all tickets/tokens\n Initialize Ticket(s) "
+    ID_AUTO_RENEW           "Automatically attempt to renew tickets"
+END
+
+STRINGTABLE
+BEGIN
+    ID_RENEW_TICKET         "Re-activate all tickets/tokens\n Renew Tickets(s) "
+    ID_DESTROY_TICKET       "Dispose of all tickets/tokens\n Destroy Ticket(s) "
+    ID_SYN_TIME             "Synchronize Time\n Synchronize Time  "
+    ID_CHANGE_PASSWORD      "Modify password\n Change Password "
+    ID_UPDATE_DISPLAY       "Refresh ticket tree display\n Update Display "
+    ID_DEBUG_MODE           "Show or hide the Debug window"
+    ID_CFG_FILES            "Configure dialog"
+END
+
+STRINGTABLE
+BEGIN
+    ID_KILL_TIX_ONEXIT      "Dispose of or keep tickets/tokens upon exiting Leash"
+    ID_LARGE_ICONS          "Show large or small tree icons"
+    ID_UPPERCASE_REALM      "Force upper or lower case realm name"
+    ID_OPTIONS_RESETWINDOWSIZE
+                            "Puts Leash's main window back to it's default size "
+    ID_RESET_WINDOW_SIZE    "Refresh Leash window to it's default size/position"
+    ID_AFS_CONTROL_PANEL    "Enables you to change settings"
+    ID_SYSTEM_CONTROL_PANEL "Open your System Properties window"
+    ID_KRB4_PROPERTIES      "Enables you to change settings"
+    ID_KRB5_PROPERTIES      "Enables you to change settings"
+    ID_LEASH_PROPERTIES     "Enables you to change settings"
+    ID_OPTIONS_LOWTICKETALARMSOUND
+                            "Turn alarm off or on,  when ticket time is low"
+    ID_LOW_TICKET_ALARM     "Turn alarm on or off, on low ticket(s)/token(s) times"
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif
+#include "res\Leash.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
diff --git a/src/windows/leash/LeashAboutBox.cpp b/src/windows/leash/LeashAboutBox.cpp
new file mode 100644 (file)
index 0000000..972514f
--- /dev/null
@@ -0,0 +1,363 @@
+//*****************************************************************************
+// File:       LeashAboutBox.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  @1998 Massachusetts Institute of Technology - All rights
+//              reserved.
+// Description:        CPP file for LeashAboutBox.h. Contains variables and functions
+//             for the Leash About Box Dialog Box
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 12/02/98    ADL     Original
+//*****************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashAboutBox.h"
+#include "reminder.h"
+#include "lglobals.h"
+#include "psapi.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashAboutBox dialog
+
+
+CLeashAboutBox::CLeashAboutBox(CWnd* pParent /*=NULL*/)
+       : CDialog(CLeashAboutBox::IDD, pParent)
+{
+    m_missingFileError = FALSE;
+
+    //{{AFX_DATA_INIT(CLeashAboutBox)
+    m_fileItem = _T("");
+    //}}AFX_DATA_INIT
+}
+
+
+void CLeashAboutBox::DoDataExchange(CDataExchange* pDX)
+{
+    CDialog::DoDataExchange(pDX);
+    //{{AFX_DATA_MAP(CLeashAboutBox)
+    DDX_Control(pDX, IDC_PROPERTIES, m_propertiesButton);
+    DDX_Control(pDX, IDC_LEASH_MODULES, m_radio_LeashDLLs);
+    DDX_Control(pDX, IDC_LEASH_MODULE_LB, m_LB_DLLsLoaded);
+    DDX_LBString(pDX, IDC_LEASH_MODULE_LB, m_fileItem);
+    //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashAboutBox, CDialog)
+    //{{AFX_MSG_MAP(CLeashAboutBox)
+    ON_WM_HSCROLL()
+    ON_LBN_SELCHANGE(IDC_LEASH_MODULE_LB, OnSelchangeLeashModuleLb)
+    ON_BN_CLICKED(IDC_ALL_MODULES, OnAllModules)
+    ON_BN_CLICKED(IDC_LEASH_MODULES, OnLeashModules)
+    ON_LBN_DBLCLK(IDC_LEASH_MODULE_LB, OnDblclkLeashModuleLb)
+    ON_BN_CLICKED(IDC_PROPERTIES, OnProperties)
+    ON_LBN_SETFOCUS(IDC_LEASH_MODULE_LB, OnSetfocusLeashModuleLb)
+    ON_BN_CLICKED(IDC_NOT_LOADED_MODULES, OnNotLoadedModules)
+    //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+;
+/////////////////////////////////////////////////////////////////////////////
+// CLeashAboutBox message handlers
+
+void CLeashAboutBox::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
+{
+    CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
+}
+
+BOOL CLeashAboutBox::GetModules95(DWORD processID, BOOL allModules)
+{
+    char szModNames[1024];
+    MODULEENTRY32 me32 = {0};
+    HANDLE hProcessSnap = NULL;
+
+    hProcessSnap = pCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processID);
+    if (hProcessSnap == (HANDLE)-1)
+        return FALSE;
+
+    me32.dwSize = sizeof(MODULEENTRY32);
+    if (pModule32First(hProcessSnap, &me32))
+    {
+        do
+        {
+            lstrcpy(szModNames, me32.szExePath);
+            strupr(szModNames);
+
+            if (!allModules)
+            {
+                if (!strstr(szModNames, "SYSTEM"))
+                    m_LB_DLLsLoaded.AddString(me32.szExePath);
+            }
+            else
+                m_LB_DLLsLoaded.AddString(me32.szExePath);
+        }
+        while (pModule32Next(hProcessSnap, &me32));
+    }
+
+    return TRUE;
+}
+
+void CLeashAboutBox::GetModulesNT(DWORD processID, BOOL allModules)
+{
+    char checkName[1024];
+    HMODULE hMods[1024];
+    HANDLE hProcess;
+    DWORD cbNeeded;
+    unsigned int i;
+
+    // Get a list of all the modules in this process.
+    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+                           FALSE, processID);
+
+    if (pEnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
+    {
+        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
+        {
+            char szModName[2048];
+
+            // Get the full path to the module's file.
+            if (pGetModuleFileNameEx(hProcess, hMods[i], szModName,
+                                     sizeof(szModName)))
+            {
+                lstrcpy(checkName, szModName);
+                strupr(checkName);
+
+                if (!allModules)
+                {
+                    if (!strstr(checkName, "SYSTEM32"))
+                        m_LB_DLLsLoaded.AddString(szModName);
+                }
+                else
+                    m_LB_DLLsLoaded.AddString(szModName);
+            }
+        }
+    }
+
+    CloseHandle(hProcess);
+}
+
+void CLeashAboutBox::HighlightFirstItem()
+{
+    UINT numModules = m_LB_DLLsLoaded.GetCount();
+    CHAR numModulesBuffer [25];
+    _itoa(numModules, numModulesBuffer, 10);
+
+    if (numModules)
+    {
+        m_LB_DLLsLoaded.SetCurSel(0);
+        m_propertiesButton.EnableWindow();
+    }
+    else
+        m_propertiesButton.EnableWindow(FALSE);
+
+    GetDlgItem(IDC_STATIC_NO_OF_MODULES)->SetWindowText(numModulesBuffer);
+}
+
+DWORD
+CLeashAboutBox::SetVersionInfo(
+    UINT id_version,
+    UINT id_copyright
+    )
+{
+    TCHAR filename[1024];
+    DWORD dwVersionHandle;
+    LPVOID pVersionInfo = 0;
+    DWORD retval = 0;
+    LPDWORD pLangInfo = 0;
+    LPTSTR szVersion = 0;
+    LPTSTR szCopyright = 0;
+    UINT len = 0;
+    TCHAR sname_version[] = TEXT("FileVersion");
+    TCHAR sname_copyright[] = TEXT("LegalCopyright");
+    TCHAR szVerQ[(sizeof("\\StringFileInfo\\12345678\\") +
+                  max(sizeof(sname_version) / sizeof(TCHAR),
+                      sizeof(sname_copyright) / sizeof(TCHAR)))];
+    TCHAR * cp = szVerQ;
+
+    if (!GetModuleFileName(NULL, filename, sizeof(filename)))
+        return GetLastError();
+
+    DWORD size = GetFileVersionInfoSize(filename, &dwVersionHandle);
+
+    if (!size)
+        return GetLastError();
+
+    pVersionInfo = malloc(size);
+    if (!pVersionInfo)
+        return ERROR_NOT_ENOUGH_MEMORY;
+
+    if (!GetFileVersionInfo(filename, dwVersionHandle, size, pVersionInfo))
+    {
+        retval = GetLastError();
+        goto cleanup;
+    }
+
+    if (!VerQueryValue(pVersionInfo, TEXT("\\VarFileInfo\\Translation"),
+                       (LPVOID*)&pLangInfo, &len))
+    {
+        retval = GetLastError();
+        goto cleanup;
+    }
+
+
+    cp += wsprintf(szVerQ,
+                   TEXT("\\StringFileInfo\\%04x%04x\\"),
+                   LOWORD(*pLangInfo), HIWORD(*pLangInfo));
+
+    lstrcpy(cp, sname_version);
+    if (!VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szVersion, &len))
+    {
+        retval = GetLastError() || ERROR_NOT_ENOUGH_MEMORY;
+        goto cleanup;
+    }
+    TCHAR version[100];
+    _sntprintf(version, sizeof(version), TEXT("Leash Version %s"), szVersion);
+    version[sizeof(version) - 1] = 0;
+    GetDlgItem(id_version)->SetWindowText(version);
+
+    lstrcpy(cp, sname_copyright);
+    if (!VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szCopyright, &len))
+    {
+        retval = GetLastError() || ERROR_NOT_ENOUGH_MEMORY;
+        goto cleanup;
+    }
+    GetDlgItem(id_copyright)->SetWindowText(szCopyright);
+
+ cleanup:
+    if (pVersionInfo)
+        free(pVersionInfo);
+    return retval;
+}
+
+BOOL CLeashAboutBox::OnInitDialog()
+{
+    CDialog::OnInitDialog();
+
+    // XXX - we need to add some sensible behavior on error.
+    SetVersionInfo(IDC_ABOUT_VERSION, IDC_ABOUT_COPYRIGHT);
+
+    if (!CLeashApp::m_hToolHelp32 && !CLeashApp::m_hPsapi)
+        m_missingFileError = TRUE;
+
+    m_radio_LeashDLLs.SetCheck(TRUE);
+    OnLeashModules();
+
+    // We need to get the version info and display it...
+    HighlightFirstItem();
+
+    if (!CLeashApp::m_hPsapi)
+        GetDlgItem(IDC_PROPERTIES)->EnableWindow(FALSE);
+
+    return TRUE;  // return TRUE unless you set the focus to a control
+    // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CLeashAboutBox::OnSelchangeLeashModuleLb()
+{
+}
+
+void CLeashAboutBox::OnAllModules()
+{
+    if (!CLeashApp::m_hToolHelp32 && !CLeashApp::m_hPsapi)
+        return; //error
+
+    m_LB_DLLsLoaded.ResetContent();
+
+    if (!CLeashApp::m_hPsapi)
+        GetModules95(GetCurrentProcessId());
+    //m_LB_DLLsLoaded.AddString("Doesn't work in Windows 95");
+    else
+        GetModulesNT(GetCurrentProcessId());
+
+    HighlightFirstItem();
+}
+
+void CLeashAboutBox::OnLeashModules()
+{
+    if (!CLeashApp::m_hToolHelp32 && !CLeashApp::m_hPsapi)
+        return; // error
+
+    m_LB_DLLsLoaded.ResetContent();
+
+    if (!CLeashApp::m_hPsapi)
+        GetModules95(GetCurrentProcessId(), FALSE);
+    //m_LB_DLLsLoaded.AddString("Doesn't work in Windows 95");
+    else
+        GetModulesNT(GetCurrentProcessId(), FALSE);
+
+    HighlightFirstItem();
+}
+
+void CLeashAboutBox::OnNotLoadedModules()
+{
+    m_LB_DLLsLoaded.ResetContent();
+
+    if (!CLeashApp::m_hKrb4DLL)
+        m_LB_DLLsLoaded.AddString(KERB4DLL);
+
+    if (!CLeashApp::m_hKrb5DLL)
+        m_LB_DLLsLoaded.AddString(KERB5DLL);
+
+    // NOTE: If the snippet below is commented back in,
+    // it should read
+    // if (!CLeashApp::m_hAfsDLL)
+    // m_LB_DLLsLoaded.AddString(AFSAuthentDLL());
+
+    //if (!CLeashApp::m_hAfsDLL)
+    //m_LB_DLLsLoaded.AddString(ASFDLL);
+
+    HighlightFirstItem();
+}
+
+void CLeashAboutBox::OnDblclkLeashModuleLb()
+{
+    m_LB_DLLsLoaded.GetText(m_LB_DLLsLoaded.GetCurSel(), m_fileItem);
+
+    SHELLEXECUTEINFO sei;
+    ZeroMemory(&sei,sizeof(sei));
+    sei.cbSize = sizeof(sei);
+    sei.lpFile = m_fileItem;
+    sei.lpVerb = "properties";
+    sei.fMask  = SEE_MASK_INVOKEIDLIST;
+
+    if (!ShellExecuteEx(&sei))
+    {
+        MessageBox("Can't find selected file or Properties dialog", "Error",
+                   MB_OK);
+    }
+}
+
+void CLeashAboutBox::OnProperties()
+{
+    OnDblclkLeashModuleLb();
+}
+
+void CLeashAboutBox::OnSetfocusLeashModuleLb()
+{
+    if (m_LB_DLLsLoaded.GetCount())
+        m_propertiesButton.EnableWindow(TRUE);
+}
+
+BOOL CLeashAboutBox::PreTranslateMessage(MSG* pMsg)
+{
+    if (m_missingFileError)
+    {
+        ::MessageBox(NULL, "OnInitDialog::We can't find file\"PSAPI.DLL\" "
+                     "or \"KERNEL32.DLL\"!!!\n"
+                     "About Box will not work properly.",
+                     "Error", MB_OK);
+
+        m_missingFileError = FALSE;
+    }
+    return CDialog::PreTranslateMessage(pMsg);
+}
diff --git a/src/windows/leash/LeashAboutBox.h b/src/windows/leash/LeashAboutBox.h
new file mode 100644 (file)
index 0000000..34e1dac
--- /dev/null
@@ -0,0 +1,81 @@
+//*****************************************************************************
+// File:       LeashAboutBox.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  @1998 Massachusetts Institute of Technology - All rights
+//              reserved.
+// Description:        H file for LeashAboutBox.cpp. Contains variables and functions
+//             for the Leash About Box Dialog Box
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 12/02/98    ADL     Original
+//*****************************************************************************
+
+
+#if !defined(AFX_LEASHABOUTBOX_H__B49E3501_4801_11D2_8F7D_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHABOUTBOX_H__B49E3501_4801_11D2_8F7D_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashAboutBox.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashAboutBox dialog
+
+class CLeashAboutBox : public CDialog
+{
+    BOOL m_missingFileError;
+    DWORD SetVersionInfo(UINT id_ver, UINT id_copyright);
+    BOOL GetModules95(DWORD processID, BOOL allModules = TRUE);
+    void GetModulesNT(DWORD processID, BOOL allModules = TRUE);
+    void HighlightFirstItem();
+
+// Construction
+public:
+    CLeashAboutBox(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+    //{{AFX_DATA(CLeashAboutBox)
+    enum { IDD = IDD_LEASH_ABOUTBOX };
+    CButton    m_propertiesButton;
+    CButton    m_radio_LeashDLLs;
+    CListBox   m_LB_DLLsLoaded;
+    CString    m_fileItem;
+    //}}AFX_DATA
+
+
+// Overrides
+    // ClassWizard generated virtual function overrides
+    //{{AFX_VIRTUAL(CLeashAboutBox)
+public:
+    virtual BOOL PreTranslateMessage(MSG* pMsg);
+protected:
+    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+    //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+    // Generated message map functions
+    //{{AFX_MSG(CLeashAboutBox)
+    afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+    virtual BOOL OnInitDialog();
+    afx_msg void OnSelchangeLeashModuleLb();
+    afx_msg void OnAllModules();
+    afx_msg void OnLeashModules();
+    afx_msg void OnDblclkLeashModuleLb();
+    afx_msg void OnProperties();
+    afx_msg void OnSetfocusLeashModuleLb();
+    afx_msg void OnNotLoadedModules();
+    //}}AFX_MSG
+    DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHABOUTBOX_H__B49E3501_4801_11D2_8F7D_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashControlPanel.cpp b/src/windows/leash/LeashControlPanel.cpp
new file mode 100644 (file)
index 0000000..47273a0
--- /dev/null
@@ -0,0 +1,43 @@
+// LeashControlPanel.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashControlPanel.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashControlPanel dialog
+
+
+CLeashControlPanel::CLeashControlPanel(CWnd* pParent /*=NULL*/)
+       : CDialog(CLeashControlPanel::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CLeashControlPanel)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CLeashControlPanel::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CLeashControlPanel)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashControlPanel, CDialog)
+       //{{AFX_MSG_MAP(CLeashControlPanel)
+               // NOTE: the ClassWizard will add message map macros here
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashControlPanel message handlers
diff --git a/src/windows/leash/LeashControlPanel.h b/src/windows/leash/LeashControlPanel.h
new file mode 100644 (file)
index 0000000..173dd6e
--- /dev/null
@@ -0,0 +1,46 @@
+#if !defined(AFX_LEASHCONTROLPANEL_H__940146F3_6857_11D2_943C_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHCONTROLPANEL_H__940146F3_6857_11D2_943C_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashControlPanel.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashControlPanel dialog
+
+class CLeashControlPanel : public CDialog
+{
+// Construction
+public:
+       CLeashControlPanel(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CLeashControlPanel)
+       enum { IDD = IDD_LEASH_CONTROL_PANEL };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashControlPanel)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CLeashControlPanel)
+               // NOTE: the ClassWizard will add member functions here
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHCONTROLPANEL_H__940146F3_6857_11D2_943C_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashDebugWindow.cpp b/src/windows/leash/LeashDebugWindow.cpp
new file mode 100644 (file)
index 0000000..6e12903
--- /dev/null
@@ -0,0 +1,187 @@
+//     **************************************************************************************
+//     File:                   LeashDebugWindow.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashDebugWindow.h. Contains variables and functions
+//                                     for the Leash Debug Window
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashDebugWindow.h"
+#include "lglobals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashDebugWindow dialog
+
+
+CLeashDebugWindow::CLeashDebugWindow(CWnd* pParent /*=NULL*/)
+       : CDialog(CLeashDebugWindow::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CLeashDebugWindow)
+       //}}AFX_DATA_INIT
+
+       m_pView = NULL;
+}
+
+CLeashDebugWindow::CLeashDebugWindow(CFormView* pView)
+{
+       m_pView = pView;
+}
+
+void CLeashDebugWindow::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CLeashDebugWindow)
+       DDX_Control(pDX, IDC_DEBUG_LISTBOX, m_debugListBox);
+       DDX_Control(pDX, IDC_LOG_FILE_LOCATION_TEXT, m_debugFile);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashDebugWindow, CDialog)
+       //{{AFX_MSG_MAP(CLeashDebugWindow)
+       ON_WM_SHOWWINDOW()
+       ON_BN_CLICKED(IDC_COPY_TO_CLIPBOARD, OnCopyToClipboard)
+       ON_WM_DESTROY()
+       ON_WM_CLOSE()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashDebugWindow message handlers
+
+
+BOOL CLeashDebugWindow::Create(const LPCSTR debugFilePath)
+{
+       m_debugFilePath = debugFilePath;
+       return CDialog::Create(CLeashDebugWindow::IDD);
+}
+
+
+void CLeashDebugWindow::OnCancel()
+{
+       if (m_pView != NULL)
+       {
+               CWinApp* pApp;
+               pApp = AfxGetApp();
+               pApp->WriteProfileInt("Settings", "DebugWindow", FALSE_FLAG);
+               m_pView->PostMessage(WM_GOODBYE, IDCANCEL);     // modeless case
+        pset_krb_debug(OFF);
+           pset_krb_ap_req_debug(OFF);
+    }
+       else
+       {
+               CDialog::OnCancel(); // modal case
+       }
+}
+
+void CLeashDebugWindow::OnOK()
+{
+       if (m_pView != NULL)
+       {
+               // modeless case
+               UpdateData(TRUE);
+               m_pView->PostMessage(WM_GOODBYE, IDOK);
+       }
+       else
+       {
+               CDialog::OnOK(); // modal case
+       }
+}
+
+BOOL CLeashDebugWindow::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+       // Set Debug flags
+       pset_krb_debug(ON); //(int)m_debugListBox.GetSafeHwnd()
+    pset_krb_ap_req_debug(ON);
+
+       if (*m_debugFilePath != 0)
+         SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, m_debugFilePath);
+    else
+         SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, "Not Available");
+
+       if (!m_debugListBox.GetCount())
+         GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(FALSE);
+
+       m_CopyButton = FALSE;
+
+       return TRUE;  // return TRUE unless you set the focus to a control
+                     // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CLeashDebugWindow::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+       CDialog::OnShowWindow(bShow, nStatus);
+}
+
+void CLeashDebugWindow::OnCopyToClipboard()
+{
+    if (!OpenClipboard())
+       {
+        MessageBox("Unable to open Clipboard!", "Error", MB_OK);
+               return;
+       }
+
+       EmptyClipboard();
+
+    int maxItems = m_debugListBox.GetCount();
+       const int MAX_MEM = maxItems * 90; // 90 chars per line seems safe like a safe bet
+
+       HGLOBAL hDebugText = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, MAX_MEM);
+    if (NULL != hDebugText)
+    {
+               CString listboxItem;
+               LPSTR pDebugText = (LPSTR) GlobalLock(hDebugText);
+               if (!pDebugText)
+               {
+                   MessageBox("Unable to write to Clipboard!", "Error", MB_OK);
+                       ASSERT(pDebugText);
+                       return;
+               }
+
+               *pDebugText = 0;
+               for (int xItem = 0; xItem < maxItems; xItem++)
+               {
+                       m_debugListBox.GetText(xItem, listboxItem);
+                       strcat(pDebugText, listboxItem);
+                       strcat(pDebugText, "\r\n");
+               }
+
+               GlobalUnlock(hDebugText);
+    }
+
+    if (NULL != hDebugText)
+        SetClipboardData(CF_TEXT, hDebugText);
+
+       CloseClipboard();
+       MessageBox("Copy to Clipboard was Successful!\r\n Paste it in your favorite editor.",
+                "Note", MB_OK);
+}
+
+BOOL CLeashDebugWindow::PreTranslateMessage(MSG* pMsg)
+{
+       if (!m_CopyButton && m_debugListBox.GetCount())
+       {
+               m_CopyButton = TRUE;
+               GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(TRUE);
+       }
+
+       return CDialog::PreTranslateMessage(pMsg);
+}
diff --git a/src/windows/leash/LeashDebugWindow.h b/src/windows/leash/LeashDebugWindow.h
new file mode 100644 (file)
index 0000000..4989370
--- /dev/null
@@ -0,0 +1,78 @@
+//     **************************************************************************************
+//     File:                   LeashDebugWindow.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashDebugWindow.cpp. Contains variables and functions
+//                                     for the Leash Debug Window
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_LEASHDEBUGWINDOW_H__DB6F7EE8_570E_11D2_9460_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHDEBUGWINDOW_H__DB6F7EE8_570E_11D2_9460_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashDebugWindow.h
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashDebugWindow dialog
+
+#define WM_GOODBYE WM_USER + 5
+
+class CLeashDebugWindow : public CDialog
+{
+private:
+       BOOL m_CopyButton;
+       CFormView* m_pView;
+       CString m_debugFilePath;
+
+// Construction
+public:
+       CLeashDebugWindow(CWnd* pParent = NULL);
+       CLeashDebugWindow(CFormView* pView);
+       BOOL Create(const LPCSTR debugFilePath);
+
+
+// Dialog Data
+       //{{AFX_DATA(CLeashDebugWindow)
+       enum { IDD = IDD_LEASH_DEBUG_WINDOW };
+       CStatic m_debugFile;
+       CListBox        m_debugListBox;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashDebugWindow)
+       public:
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CLeashDebugWindow)
+       virtual void OnCancel();
+       virtual void OnOK();
+       afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+       afx_msg void OnCopyToClipboard();
+       virtual BOOL OnInitDialog();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHDEBUGWINDOW_H__DB6F7EE8_570E_11D2_9460_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashDoc.cpp b/src/windows/leash/LeashDoc.cpp
new file mode 100644 (file)
index 0000000..af4a9b8
--- /dev/null
@@ -0,0 +1,94 @@
+//     **************************************************************************************
+//     File:                   LeashDoc.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashDoc.h. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "Leash.h"
+
+#include "LeashDoc.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// LeashDoc
+
+IMPLEMENT_DYNCREATE(LeashDoc, CDocument)
+
+BEGIN_MESSAGE_MAP(LeashDoc, CDocument)
+       //{{AFX_MSG_MAP(LeashDoc)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// LeashDoc construction/destruction
+
+LeashDoc::LeashDoc()
+{
+       // TODO: add one-time construction code here
+
+}
+
+LeashDoc::~LeashDoc()
+{
+}
+
+BOOL LeashDoc::OnNewDocument()
+{
+       if (!CDocument::OnNewDocument())
+               return FALSE;
+
+       // TODO: add reinitialization code here
+       // (SDI documents will reuse this document)
+
+       return TRUE;
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// LeashDoc serialization
+
+void LeashDoc::Serialize(CArchive& ar)
+{
+       if (ar.IsStoring())
+       {
+               // TODO: add storing code here
+       }
+       else
+       {
+               // TODO: add loading code here
+       }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// LeashDoc diagnostics
+
+#ifdef _DEBUG
+void LeashDoc::AssertValid() const
+{
+       CDocument::AssertValid();
+}
+
+void LeashDoc::Dump(CDumpContext& dc) const
+{
+       CDocument::Dump(dc);
+}
+#endif //_DEBUG
+
+/////////////////////////////////////////////////////////////////////////////
+// LeashDoc commands
diff --git a/src/windows/leash/LeashDoc.h b/src/windows/leash/LeashDoc.h
new file mode 100644 (file)
index 0000000..33b2fd9
--- /dev/null
@@ -0,0 +1,66 @@
+//     **************************************************************************************
+//     File:                   LeashDoc.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashDoc.cpp. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_LeashDOC_H__6F45AD97_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
+#define AFX_LeashDOC_H__6F45AD97_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+
+class LeashDoc : public CDocument
+{
+protected: // create from serialization only
+       LeashDoc();
+       DECLARE_DYNCREATE(LeashDoc)
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(LeashDoc)
+       public:
+       virtual BOOL OnNewDocument();
+       virtual void Serialize(CArchive& ar);
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~LeashDoc();
+#ifdef _DEBUG
+       virtual void AssertValid() const;
+       virtual void Dump(CDumpContext& dc) const;
+#endif
+
+protected:
+
+// Generated message map functions
+protected:
+       //{{AFX_MSG(LeashDoc)
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LeashDOC_H__6F45AD97_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/LeashFileDialog.cpp b/src/windows/leash/LeashFileDialog.cpp
new file mode 100644 (file)
index 0000000..7e45f42
--- /dev/null
@@ -0,0 +1,75 @@
+//     **************************************************************************************
+//     File:                   LeashFileDialog.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashFileDialog.h. Contains variables and functions
+//                                     for the Leash File Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashFileDialog.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashFileDialog
+
+IMPLEMENT_DYNAMIC(CLeashFileDialog, CFileDialog)
+
+
+
+CLeashFileDialog::CLeashFileDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
+               LPCTSTR lpszFilter, DWORD dwFlags, CWnd* pParentWnd) :
+               CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
+{
+       m_ofn.Flags |= OFN_ENABLETEMPLATE;
+       m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILESPECIAL);
+       m_ofn.lpstrFilter = lpszFilter;
+       m_ofn.lpstrFileTitle = m_lpstrFileTitle;
+       m_ofn.nMaxFileTitle = MAX_PATH;
+       *m_lpstrFileTitle = 0;
+       BOOL m_startup = TRUE;
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashFileDialog, CFileDialog)
+       //{{AFX_MSG_MAP(CLeashFileDialog)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+BOOL CLeashFileDialog::OnInitDialog()
+{
+       BOOL bRet = CFileDialog::OnInitDialog();
+       if (bRet == TRUE)
+       {
+               GetParent()->GetDlgItem(IDOK)->SetWindowText("&OK");
+               //GetParent()->GetDlgItem(IDOK)->EnableWindow(FALSE);
+       }
+
+       return bRet;
+}
+
+void CLeashFileDialog::OnFileNameChange( )
+{
+       if (!m_startup)
+       { //' keeps the OK button disabled until a real select is made
+               CString testString = GetFileName();
+               if (-1 == testString.Find('*'))
+                 GetParent()->GetDlgItem(IDOK)->EnableWindow();
+       }
+         else
+           m_startup = FALSE;
+}
diff --git a/src/windows/leash/LeashFileDialog.h b/src/windows/leash/LeashFileDialog.h
new file mode 100644 (file)
index 0000000..aef156d
--- /dev/null
@@ -0,0 +1,57 @@
+//     **************************************************************************************
+//     File:                   LeashFileDialog.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashFileDialog.cpp. Contains variables and functions
+//                                     for the Leash File Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_LEASHFILEDIALOG_H__E74500E1_6B74_11D2_9448_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHFILEDIALOG_H__E74500E1_6B74_11D2_9448_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashFileDialog.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashFileDialog dialog
+
+class CLeashFileDialog : public CFileDialog
+{
+       DECLARE_DYNAMIC(CLeashFileDialog)
+
+private:
+       CHAR m_lpstrFileTitle[MAX_PATH];
+       BOOL m_startup;
+
+public:
+       CLeashFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
+                                        LPCTSTR lpszDefExt = NULL,
+                                        LPCTSTR lpszFileName = NULL,
+                                        LPCTSTR lpszFilter = NULL,
+                     DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST,
+                                        CWnd* pParentWnd = NULL);
+
+               CString GetSelectedFileName() {return m_lpstrFileTitle;}
+
+protected:
+       //{{AFX_MSG(CLeashFileDialog)
+       virtual BOOL OnInitDialog();
+       virtual void OnFileNameChange( );
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHFILEDIALOG_H__E74500E1_6B74_11D2_9448_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashFrame.cpp b/src/windows/leash/LeashFrame.cpp
new file mode 100644 (file)
index 0000000..f7e4b56
--- /dev/null
@@ -0,0 +1,119 @@
+//     **************************************************************************************
+//     File:                   LeashFrame.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashFrame.h. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "LeashFrame.h"
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char BASED_CODE THIS_FILE[] = __FILE__;
+#endif
+///////////////////////////////////////////////////////////////
+// CLeashFrame
+
+const CRect CLeashFrame::s_rectDefault(0, 0, 740, 400);  // static public (l,t,r,b)
+const char CLeashFrame::s_profileHeading[] = "Window size";
+const char CLeashFrame::s_profileRect[] = "Rect";
+const char CLeashFrame::s_profileIcon[] = "icon";
+const char CLeashFrame::s_profileMax[] = "max";
+const char CLeashFrame::s_profileTool[] = "tool";
+const char CLeashFrame::s_profileStatus[] = "status";
+
+IMPLEMENT_DYNAMIC(CLeashFrame, CFrameWnd)
+
+BEGIN_MESSAGE_MAP(CLeashFrame, CFrameWnd)
+       //{{AFX_MSG_MAP(CLeashFrame)
+       ON_WM_DESTROY()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+///////////////////////////////////////////////////////////////
+CLeashFrame::CLeashFrame()
+{
+    m_bFirstTime = TRUE;
+}
+
+///////////////////////////////////////////////////////////////
+CLeashFrame::~CLeashFrame()
+{
+}
+
+///////////////////////////////////////////////////////////////
+void CLeashFrame::OnDestroy()
+{
+       CString strText;
+       BOOL bIconic, bMaximized;
+
+       WINDOWPLACEMENT wndpl;
+       wndpl.length = sizeof(WINDOWPLACEMENT);
+       // gets current window position and
+       //  iconized/maximized status
+       BOOL bRet = GetWindowPlacement(&wndpl);
+       if (wndpl.showCmd == SW_SHOWNORMAL)
+       {
+               bIconic = FALSE;
+               bMaximized = FALSE;
+       }
+       else if (wndpl.showCmd == SW_SHOWMAXIMIZED)
+       {
+               bIconic = FALSE;
+               bMaximized = TRUE;
+       }
+       else if (wndpl.showCmd == SW_SHOWMINIMIZED)
+       {
+               bIconic = TRUE;
+               if (wndpl.flags)
+               {
+                       bMaximized = TRUE;
+               }
+               else
+               {
+                       bMaximized = FALSE;
+               }
+       }
+
+       strText.Format("%04d %04d %04d %04d",
+                      wndpl.rcNormalPosition.left,
+                      wndpl.rcNormalPosition.top,
+                      wndpl.rcNormalPosition.right,
+                      wndpl.rcNormalPosition.bottom);
+
+       AfxGetApp()->WriteProfileString(s_profileHeading,
+                                       s_profileRect, strText);
+
+       AfxGetApp()->WriteProfileInt(s_profileHeading,
+                                    s_profileIcon, bIconic);
+
+       AfxGetApp()->WriteProfileInt(s_profileHeading,
+                                    s_profileMax, bMaximized);
+
+       SaveBarState(AfxGetApp()->m_pszProfileName);
+
+       CFrameWnd::OnDestroy();
+}
+
+///////////////////////////////////////////////////////////////
+void CLeashFrame::ActivateFrame(int nCmdShow)
+{
+
+    if (m_bFirstTime)
+       {
+               m_bFirstTime = FALSE;
+
+        LoadBarState(AfxGetApp()->m_pszProfileName);
+    }
+
+       CFrameWnd::ActivateFrame(nCmdShow);
+}
diff --git a/src/windows/leash/LeashFrame.h b/src/windows/leash/LeashFrame.h
new file mode 100644 (file)
index 0000000..6d45e78
--- /dev/null
@@ -0,0 +1,50 @@
+//     **************************************************************************************
+//     File:                   LeashFrame.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashFrame.cpp. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#ifndef _LEASH_PERSISTENT_FRAME
+#define _LEASH_PERSISTENT_FRAME
+
+class CLeashFrame : public CFrameWnd
+{ // remembers where it was on the desktop
+       DECLARE_DYNAMIC(CLeashFrame)
+    static const CRect s_rectDefault;
+       static const char s_profileHeading[];
+       static const char s_profileRect[];
+       static const char s_profileIcon[];
+       static const char s_profileMax[];
+       static const char s_profileTool[];
+       static const char s_profileStatus[];
+
+  private:
+       BOOL m_bFirstTime;
+
+  protected: // Create from serialization only
+       CLeashFrame();
+       ~CLeashFrame();
+
+       //{{AFX_VIRTUAL(CLeashFrame)
+       public:
+       virtual void ActivateFrame(int nCmdShow = -1);
+       protected:
+       //}}AFX_VIRTUAL
+
+       //{{AFX_MSG(CLeashFrame)
+       afx_msg void OnDestroy();
+       //}}AFX_MSG
+
+       DECLARE_MESSAGE_MAP()
+};
+
+#endif // _LEASH_PERSISTENT_FRAME
diff --git a/src/windows/leash/LeashMessageBox.cpp b/src/windows/leash/LeashMessageBox.cpp
new file mode 100644 (file)
index 0000000..0fd2182
--- /dev/null
@@ -0,0 +1,83 @@
+//     **************************************************************************************
+//     File:                   LeashMessageBox.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashMessageBox.h. Contains variables and functions
+//                                     for the Leash Special Message Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashMessageBox.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+DWORD CLeashMessageBox ::m_dwTime;
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashMessageBox dialog
+
+CLeashMessageBox::CLeashMessageBox(CWnd* pParent, const CString msgText, DWORD dwTime)
+       : CDialog(CLeashMessageBox::IDD, pParent)
+{
+       m_dwTime = dwTime;
+
+       //{{AFX_DATA_INIT(CLeashMessageBox)
+       m_messageText = _T(msgText);
+       //}}AFX_DATA_INIT
+}
+
+CLeashMessageBox::~CLeashMessageBox()
+{
+}
+
+void CLeashMessageBox::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CLeashMessageBox)
+       DDX_Text(pDX, IDC_LEASH_WARNING_MSG, m_messageText);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashMessageBox, CDialog)
+       //{{AFX_MSG_MAP(CLeashMessageBox)
+       ON_WM_DESTROY()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashMessageBox message handlers
+
+void CALLBACK CLeashMessageBox::MessageBoxTimer(HWND hwnd, UINT uiMsg, UINT idEvent, DWORD dwTime)
+{
+       ::KillTimer(hwnd, 2);
+       ::SendMessage(hwnd, WM_CLOSE, 0, 0);
+}
+
+void CLeashMessageBox::OnOK()
+{
+       KillTimer(2);
+    SendMessage(WM_CLOSE, 0, 0);
+}
+
+BOOL CLeashMessageBox::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+       UINT idTimer = SetTimer(2, m_dwTime, (TIMERPROC)MessageBoxTimer);
+
+       return TRUE;  // return TRUE unless you set the focus to a control
+                     // EXCEPTION: OCX Property Pages should return FALSE
+}
diff --git a/src/windows/leash/LeashMessageBox.h b/src/windows/leash/LeashMessageBox.h
new file mode 100644 (file)
index 0000000..57f1360
--- /dev/null
@@ -0,0 +1,70 @@
+//     **************************************************************************************
+//     File:                   LeashMessageBox.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashMessageBox.cpp. Contains variables and functions
+//                                     for the Leash Special Message Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_LEASHMESSAGEBOX_H__865865B6_56F6_11D2_945F_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHMESSAGEBOX_H__865865B6_56F6_11D2_945F_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashMessageBox.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashMessageBox dialog
+
+#include "windows.h"
+
+class CLeashMessageBox : public CDialog
+{
+private:
+       static DWORD m_dwTime;
+       static void CALLBACK MessageBoxTimer(HWND hwnd, UINT uiMsg, UINT idEvent, DWORD dwTime);
+
+       // Construction
+public:
+       CLeashMessageBox(CWnd* pParent = NULL,            const CString msgText = "Place your message here!!!",
+                                        DWORD dwTime = 0);
+       ~CLeashMessageBox();
+
+// Dialog Data
+       //{{AFX_DATA(CLeashMessageBox)
+       enum { IDD = IDD_MESSAGE_BOX };
+       CString m_messageText;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashMessageBox)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CLeashMessageBox)
+       virtual BOOL OnInitDialog();
+       virtual void OnOK();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHMESSAGEBOX_H__865865B6_56F6_11D2_945F_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashProperties.cpp b/src/windows/leash/LeashProperties.cpp
new file mode 100644 (file)
index 0000000..2854231
--- /dev/null
@@ -0,0 +1,202 @@
+//     **************************************************************************************
+//     File:                   LeashProperties.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for LeashProperties.h. Contains variables and functions
+//                                     for the Leash Properties Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+#include "stdafx.h"
+#include "leash.h"
+#include "LeashProperties.h"
+#include "LeashMessageBox.h"
+#include <leashinfo.h>
+#include "lglobals.h"
+#include "reminder.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashProperties dialog
+
+char CLeashProperties::timeServer[255] = {NULL};
+
+CLeashProperties::CLeashProperties(CWnd* pParent /*=NULL*/)
+       : CDialog(CLeashProperties::IDD, pParent)
+{
+    m_initMissingFiles = m_newMissingFiles = 0;
+    dw_initMslsaImport = dw_newMslsaImport = 0;
+
+       //{{AFX_DATA_INIT(CLeashProperties)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CLeashProperties::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CLeashProperties)
+               // NOTE: the ClassWizard will add DDX and DDV calls here
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CLeashProperties, CDialog)
+       //{{AFX_MSG_MAP(CLeashProperties)
+       ON_BN_CLICKED(IDC_BUTTON_LEASHINI_HELP2, OnHelp)
+    ON_BN_CLICKED(IDC_CHECK_CREATE_MISSING_CFG, OnCheckMissingCfg)
+    ON_BN_CLICKED(IDC_RESET_DEFAULTS, OnButtonResetDefaults)
+    ON_BN_CLICKED(IDC_RADIO_MSLSA_IMPORT_OFF, OnRadioMslsaNever)
+    ON_BN_CLICKED(IDC_RADIO_MSLSA_IMPORT_ON,  OnRadioMslsaAlways)
+    ON_BN_CLICKED(IDC_RADIO_MSLSA_IMPORT_MATCH, OnRadioMslsaMatchingRealm)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashProperties message handlers
+
+BOOL CLeashProperties::OnInitDialog()
+{
+       CDialog::OnInitDialog();
+
+    pLeashGetTimeServerName(timeServer, TIMEHOST);
+    SetDlgItemText(IDC_EDIT_TIME_SERVER, timeServer);
+
+       if (getenv(TIMEHOST))
+        GetDlgItem(IDC_EDIT_TIME_SERVER)->EnableWindow(FALSE);
+    else
+        GetDlgItem(IDC_STATIC_TIMEHOST)->ShowWindow(FALSE);
+
+    CWinApp * pApp = AfxGetApp();
+    if (pApp)
+        m_initMissingFiles = m_newMissingFiles =
+            pApp->GetProfileInt("Settings", "CreateMissingConfig", FALSE_FLAG);
+    CheckDlgButton(IDC_CHECK_CREATE_MISSING_CFG, m_initMissingFiles);
+
+    dw_initMslsaImport = dw_newMslsaImport = pLeash_get_default_mslsa_import();
+    switch ( dw_initMslsaImport ) {
+    case 0:
+        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_OFF,TRUE);
+        break;
+    case 1:
+        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_ON,TRUE);
+        break;
+    case 2:
+        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_MATCH,TRUE);
+        break;
+    }
+
+    return TRUE;
+}
+
+void CLeashProperties::OnOK()
+{
+       CString timeServer_;
+       GetDlgItemText(IDC_EDIT_TIME_SERVER, timeServer_);
+
+       if (getenv(TIMEHOST))
+    {
+        // Check system for TIMEHOST, just in case it gets set (somehow)
+        MessageBox("Can't change the time host unless you remove it from the environment!",
+                   "Error", MB_OK);
+        return;
+    }
+
+    if( getenv("USEKRB4") !=  NULL)
+    {
+        MessageBox("Kerberos 4 ticket requests are being controlled by the environment"
+                   "variable USEKRB4 instead of the registry. Leash cannot modify"
+                   "the environment. Use the System control panel instead.",
+                    "Leash", MB_OK);
+        return;
+    }
+
+    if (SetRegistryVariable(TIMEHOST, timeServer_))
+       {
+               MessageBox("There was an error putting your entry into the Registry!",
+                   "Error", MB_OK);
+    }
+
+    if ( m_initMissingFiles != m_newMissingFiles ) {
+        CWinApp * pApp = AfxGetApp();
+        if (pApp)
+            pApp->WriteProfileInt("Settings", "CreateMissingConfig",
+                                m_newMissingFiles ? TRUE_FLAG : FALSE_FLAG);
+
+        if ( m_newMissingFiles )
+            CLeashApp::ValidateConfigFiles();
+    }
+
+    if ( dw_initMslsaImport != dw_newMslsaImport ) {
+               pLeash_set_default_mslsa_import(dw_newMslsaImport);
+       }
+
+       CDialog::OnOK();
+}
+
+void CLeashProperties::OnCheckMissingCfg()
+{
+    m_newMissingFiles = (BOOL)IsDlgButtonChecked(IDC_CHECK_CREATE_MISSING_CFG);
+}
+
+void CLeashProperties::OnRadioMslsaNever()
+{
+    dw_newMslsaImport = 0;
+}
+
+void CLeashProperties::OnRadioMslsaAlways()
+{
+    dw_newMslsaImport = 1;
+}
+
+void CLeashProperties::OnRadioMslsaMatchingRealm()
+{
+    dw_newMslsaImport = 2;
+}
+
+void CLeashProperties::OnHelp()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_LEASH_PROPERTIES_COMMAND);
+#else
+    AfxGetApp()->WinHelp(HID_LEASH_PROPERTIES_COMMAND);
+#endif
+}
+
+void CLeashProperties::OnButtonResetDefaults()
+{
+    if (IDYES != AfxMessageBox("You are about to reset all Leash settings to their default values!\n\nContinue?",
+                                MB_YESNO))
+        return;
+
+    pLeash_reset_defaults();
+
+    HKEY hKey;
+    LONG rc;
+
+    rc = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\MIT\\Leash32\\Settings",
+                      0, KEY_WRITE, &hKey);
+    if (rc)
+        return;
+
+    rc = RegDeleteValue(hKey, "AutoRenewTickets");
+    rc = RegDeleteValue(hKey, "CreateMissingConfig");
+    rc = RegDeleteValue(hKey, "DebugWindow");
+    rc = RegDeleteValue(hKey, "LargeIcons");
+    rc = RegDeleteValue(hKey, "TIMEHOST");
+    rc = RegDeleteValue(hKey, "AfsStatus");
+    rc = RegDeleteValue(hKey, "LowTicketAlarm");
+
+    RegCloseKey(hKey);
+}
diff --git a/src/windows/leash/LeashProperties.h b/src/windows/leash/LeashProperties.h
new file mode 100644 (file)
index 0000000..314eba7
--- /dev/null
@@ -0,0 +1,78 @@
+//     **************************************************************************************
+//     File:                   LeashProperties.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashProperties.cpp. Contains variables and functions
+//                                     for the Leash Properties Dialog Box
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+#if !defined(AFX_LEASHPROPERTIES_H__7E54E028_726E_11D2_945E_0000861B8A3C__INCLUDED_)
+#define AFX_LEASHPROPERTIES_H__7E54E028_726E_11D2_945E_0000861B8A3C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// LeashProperties.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashProperties dialog
+
+#define TIMEHOST "TIMEHOST"
+
+class CLeashProperties : public CDialog
+{
+private:
+       static char timeServer[255];
+       CHAR sysDir[MAX_PATH];
+    BOOL m_initMissingFiles;
+    BOOL m_newMissingFiles;
+    DWORD dw_initMslsaImport;
+    DWORD dw_newMslsaImport;
+
+// Construction
+public:
+       CLeashProperties(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CLeashProperties)
+       enum { IDD = IDD_LEASH_PROPERTIES };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashProperties)
+       public:
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CLeashProperties)
+       virtual BOOL OnInitDialog();
+       virtual void OnOK();
+       afx_msg void OnHelp();
+    afx_msg void OnCheckMissingCfg();
+    afx_msg void OnRadioMslsaNever();
+    afx_msg void OnRadioMslsaAlways();
+    afx_msg void OnRadioMslsaMatchingRealm();
+    afx_msg void OnButtonResetDefaults();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LEASHPROPERTIES_H__7E54E028_726E_11D2_945E_0000861B8A3C__INCLUDED_)
diff --git a/src/windows/leash/LeashView.cpp b/src/windows/leash/LeashView.cpp
new file mode 100644 (file)
index 0000000..a2f9333
--- /dev/null
@@ -0,0 +1,2810 @@
+//*****************************************************************************
+// File:       LeashView.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright   @1998 Massachusetts Institute of Technology - All rights reserved.
+// Description:        CPP file for LeashView.h. Contains variables and functions
+//             for the Leash FormView
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 12/02/98    ADL             Original
+// 20030508     JEA     Added
+//*****************************************************************************
+
+#include "stdafx.h"
+#include <afxpriv.h>
+#include "Leash.h"
+#include "LeashDoc.h"
+#include "LeashView.h"
+#include "MainFrm.h"
+#include "reminder.h"
+#include "lglobals.h"
+#include "LeashDebugWindow.h"
+#include "LeashMessageBox.h"
+#include "LeashAboutBox.h"
+#include "Krb4Properties.h"
+#include "Krb5Properties.h"
+#include "LeashProperties.h"
+#include "KrbProperties.h"
+#include "AfsProperties.h"
+#include <krb5.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static CHAR THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashView
+
+IMPLEMENT_DYNCREATE(CLeashView, CFormView)
+
+BEGIN_MESSAGE_MAP(CLeashView, CFormView)
+       //{{AFX_MSG_MAP(CLeashView)
+       ON_MESSAGE(WM_GOODBYE, OnGoodbye)
+    ON_MESSAGE(WM_TRAYICON, OnTrayIcon)
+    ON_NOTIFY(TVN_ITEMEXPANDED, IDC_TREEVIEW, OnItemexpandedTreeview)
+       ON_WM_CREATE()
+       ON_WM_SHOWWINDOW()
+       ON_COMMAND(ID_INIT_TICKET, OnInitTicket)
+       ON_COMMAND(ID_RENEW_TICKET, OnRenewTicket)
+    ON_COMMAND(ID_IMPORT_TICKET, OnImportTicket)
+       ON_COMMAND(ID_DESTROY_TICKET, OnDestroyTicket)
+       ON_COMMAND(ID_CHANGE_PASSWORD, OnChangePassword)
+       ON_COMMAND(ID_UPDATE_DISPLAY, OnUpdateDisplay)
+       ON_COMMAND(ID_SYN_TIME, OnSynTime)
+       ON_COMMAND(ID_DEBUG_MODE, OnDebugMode)
+       ON_COMMAND(ID_LARGE_ICONS, OnLargeIcons)
+       ON_COMMAND(ID_UPPERCASE_REALM, OnUppercaseRealm)
+       ON_COMMAND(ID_KILL_TIX_ONEXIT, OnKillTixOnExit)
+       ON_WM_DESTROY()
+       ON_UPDATE_COMMAND_UI(ID_DESTROY_TICKET, OnUpdateDestroyTicket)
+    ON_UPDATE_COMMAND_UI(ID_IMPORT_TICKET, OnUpdateImportTicket)
+       ON_UPDATE_COMMAND_UI(ID_INIT_TICKET, OnUpdateInitTicket)
+       ON_UPDATE_COMMAND_UI(ID_RENEW_TICKET, OnUpdateRenewTicket)
+       ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
+       ON_COMMAND(ID_AFS_CONTROL_PANEL, OnAfsControlPanel)
+       ON_UPDATE_COMMAND_UI(ID_DEBUG_MODE, OnUpdateDebugMode)
+       ON_UPDATE_COMMAND_UI(ID_CFG_FILES, OnUpdateCfgFiles)
+       ON_COMMAND(ID_KRB4_PROPERTIES, OnKrb4Properties)
+       ON_COMMAND(ID_KRB5_PROPERTIES, OnKrb5Properties)
+       ON_COMMAND(ID_LEASH_PROPERTIES, OnLeashProperties)
+    ON_COMMAND(ID_LEASH_RESTORE, OnLeashRestore)
+    ON_COMMAND(ID_LEASH_MINIMIZE, OnLeashMinimize)
+       ON_COMMAND(ID_LOW_TICKET_ALARM, OnLowTicketAlarm)
+       ON_COMMAND(ID_AUTO_RENEW, OnAutoRenew)
+       ON_UPDATE_COMMAND_UI(ID_KRB4_PROPERTIES, OnUpdateKrb4Properties)
+       ON_UPDATE_COMMAND_UI(ID_KRB5_PROPERTIES, OnUpdateKrb5Properties)
+       ON_UPDATE_COMMAND_UI(ID_AFS_CONTROL_PANEL, OnUpdateAfsControlPanel)
+       ON_COMMAND(ID_PROPERTIES, OnKrbProperties)
+       ON_UPDATE_COMMAND_UI(ID_PROPERTIES, OnUpdateProperties)
+       ON_COMMAND(ID_HELP_KERBEROS_, OnHelpKerberos)
+       ON_COMMAND(ID_HELP_LEASH32, OnHelpLeash32)
+       ON_COMMAND(ID_HELP_WHYUSELEASH32, OnHelpWhyuseleash32)
+       ON_WM_SIZE()
+       ON_WM_LBUTTONDOWN()
+       ON_WM_CLOSE()
+       ON_WM_HSCROLL()
+       ON_WM_VSCROLL()
+    ON_WM_SYSCOLORCHANGE()
+    ON_MESSAGE(ID_OBTAIN_TGT_WITH_LPARAM, OnObtainTGTWithParam)
+       //}}AFX_MSG_MAP
+
+END_MESSAGE_MAP()
+
+
+LONG CLeashView::m_ticketTimeLeft = 0;  // # of seconds left before tickets expire
+INT  CLeashView::m_forwardableTicket = 0;
+INT  CLeashView::m_proxiableTicket = 0;
+INT  CLeashView::m_renewableTicket = 0;
+INT  CLeashView::m_noaddressTicket = 0;
+DWORD CLeashView::m_publicIPAddress = 0;
+INT  CLeashView::m_ticketStatusAfs = 0; // Defense Condition: are we low on tickets?
+INT  CLeashView::m_ticketStatusKrb4 = 0; // Defense Condition: are we low on tickets?
+INT  CLeashView::m_ticketStatusKrb5 = 0; // Defense Condition: are we low on tickets?
+INT  CLeashView::m_warningOfTicketTimeLeftAfs = 0; // Prevents warning box from coming up repeatively
+INT  CLeashView::m_warningOfTicketTimeLeftKrb4 = 0; // Prevents warning box from coming up repeatively
+INT  CLeashView::m_warningOfTicketTimeLeftKrb5 = 0; // Prevents warning box from coming up repeatively
+INT  CLeashView::m_warningOfTicketTimeLeftLockAfs = 0;
+INT  CLeashView::m_warningOfTicketTimeLeftLockKrb4 = 0;
+INT  CLeashView::m_warningOfTicketTimeLeftLockKrb5 = 0;
+INT  CLeashView::m_updateDisplayCount;
+INT  CLeashView::m_alreadyPlayedDisplayCount;
+INT  CLeashView::m_autoRenewTickets = 0;
+BOOL CLeashView::m_lowTicketAlarmSound;
+INT  CLeashView::m_autoRenewalAttempted = 0;
+BOOL CLeashView::m_importedTickets = 0;
+LONG CLeashView::m_timerMsgNotInProgress = 1;
+
+bool change_icon_size = true;
+#ifndef KRB5_TC_NOTICKET
+extern HANDLE m_tgsReqMutex;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashView construction/destruction
+
+CLeashView::CLeashView():
+CFormView(CLeashView::IDD)
+{
+    m_listKrb4 = NULL;
+    m_listKrb5 = NULL;
+    m_listAfs = NULL;
+    m_startup = TRUE;
+    m_warningOfTicketTimeLeftKrb4 = 0;
+    m_warningOfTicketTimeLeftKrb5 = 0;
+    m_warningOfTicketTimeLeftLockKrb4 = 0;
+    m_warningOfTicketTimeLeftLockKrb5 = 0;
+    m_largeIcons = 0;
+    m_destroyTicketsOnExit = 0;
+    m_debugWindow = 0;
+    m_upperCaseRealm = 0;
+    m_lowTicketAlarm = 0;
+    m_importedTickets = 0;
+
+    m_pDebugWindow = NULL;
+    m_pDebugWindow = new CLeashDebugWindow(this);
+    if (!m_pDebugWindow)
+    {
+        AfxMessageBox("There is a problem with the Leash Debug Window!",
+                   MB_OK|MB_ICONSTOP);
+    }
+
+    m_debugStartUp = TRUE;
+    m_isMinimum = FALSE;
+    m_lowTicketAlarmSound = FALSE;
+    m_alreadyPlayed = FALSE;
+    ResetTreeNodes();
+    m_pTree = NULL;
+    m_hMenu = NULL;
+    m_pApp = NULL;
+    m_pImageList = NULL;
+    m_forwardableTicket = 0;
+    m_proxiableTicket = 0;
+    m_renewableTicket = 0;
+    m_noaddressTicket = 0;
+    m_publicIPAddress = 0;
+    m_autoRenewTickets = 0;
+    m_autoRenewalAttempted = 0;
+
+    m_bIconAdded = FALSE;
+    m_bIconDeleted = FALSE;
+#ifndef KRB5_TC_NOTICKET
+    m_tgsReqMutex = CreateMutex(NULL, FALSE, NULL);
+#endif
+}
+
+
+CLeashView::~CLeashView()
+{
+#ifndef KRB5_TC_NOTICKET
+    CloseHandle(m_tgsReqMutex);
+#endif
+    // destroys window if not already destroyed
+    if (m_pDebugWindow)
+        delete m_pDebugWindow;
+}
+
+BOOL CLeashView::PreCreateWindow(CREATESTRUCT& cs)
+{
+    // TODO: Modify the Window class or styles here by modifying
+    //  the CREATESTRUCT cs
+
+    return CFormView::PreCreateWindow(cs);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashView diagnostics
+
+#ifdef _DEBUG
+VOID CLeashView::AssertValid() const
+{
+    CFormView::AssertValid();
+}
+
+VOID CLeashView::Dump(CDumpContext& dc) const
+{
+    CFormView::Dump(dc);
+}
+
+/*
+LeashDoc* CLeashView::GetDocument() // non-debug version is inline
+{
+    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(LeashDoc)));
+    return (LeashDoc*)m_pDocument;
+}
+*/
+#endif //_DEBUG
+
+/////////////////////////////////////////////////////////////////////////////
+// CLeashView message handlers
+
+BOOL CLeashView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
+                        DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
+                        UINT nID, CCreateContext* pContext)
+{
+    return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect,
+                             pParentWnd, nID, pContext);
+}
+
+INT CLeashView::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+    if (CFormView::OnCreate(lpCreateStruct) == -1)
+        return -1;
+    return 0;
+}
+
+VOID CLeashView::OnClose(void)
+{
+    printf("OnClose\n");
+}
+
+LONG CLeashView::LeashTime()
+{
+    _tzset();
+    return time(0);
+}
+
+// Call while possessing a lock to ticketinfo.lockObj
+INT CLeashView::GetLowTicketStatus(int ver)
+{
+    BOOL b_notix = (ver == 4 && !ticketinfo.Krb4.btickets) ||
+                   (ver == 5 && !ticketinfo.Krb5.btickets) ||
+                   (ver == 1 && !ticketinfo.Afs.btickets);
+
+    if (b_notix)
+        return NO_TICKETS;
+
+    if (m_ticketTimeLeft <= 0L)
+        return ZERO_MINUTES_LEFT;
+
+    if (m_ticketTimeLeft <= 20 * 60)
+        return (INT)(m_ticketTimeLeft / 5 / 60) + 2 -
+            (m_ticketTimeLeft % (5 * 60) == 0 ? 1 : 0);
+
+    return PLENTY_OF_TIME;
+}
+
+VOID CLeashView::UpdateTicketTime(TICKETINFO& ti)
+{
+    if (!ti.btickets)
+    {
+        m_ticketTimeLeft = 0L;
+        return;
+    }
+
+    m_ticketTimeLeft = ti.issue_date + ti.lifetime -
+        LeashTime();
+
+    if (m_ticketTimeLeft <= 0L)
+        ti.btickets = EXPIRED_TICKETS;
+}
+
+
+VOID CALLBACK EXPORT CLeashView::TimerProc(HWND hWnd, UINT nMsg,
+                                           UINT nIDEvent, DWORD dwTime)
+{
+    // All of the work is being done in the PreTranslateMessage method
+    // in order to have access to the object
+}
+
+VOID  CLeashView::ApplicationInfoMissingMsg()
+{
+    AfxMessageBox("There is a problem finding Leash application information!",
+               MB_OK|MB_ICONSTOP);
+}
+
+VOID CLeashView::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+    CFormView::OnShowWindow(bShow, nStatus);
+
+    // Get State of Icons Size
+    m_pApp = AfxGetApp();
+    if (!m_pApp)
+    {
+        ApplicationInfoMissingMsg();
+    }
+    else
+    {
+        m_largeIcons = m_pApp->GetProfileInt("Settings", "LargeIcons", ON);
+
+        // Get State of Destroy Tickets On Exit
+        m_destroyTicketsOnExit = m_pApp->GetProfileInt("Settings", "DestroyTicketsOnExit", OFF);
+
+        // Get State of Low Ticket Alarm
+        m_lowTicketAlarm = m_pApp->GetProfileInt("Settings", "LowTicketAlarm", ON);
+
+        // Get State of Auto Renew Tickets
+        m_autoRenewTickets = m_pApp->GetProfileInt("Settings", "AutoRenewTickets", ON);
+
+        // Get State of Upper Case Realm
+        m_upperCaseRealm = pLeash_get_default_uppercaserealm();
+
+        // Forwardable flag
+        m_forwardableTicket = pLeash_get_default_forwardable();
+
+        // Proxiable flag
+        m_proxiableTicket = pLeash_get_default_proxiable();
+
+        // Renewable flag
+        m_renewableTicket = pLeash_get_default_renewable();
+
+        // No Address flag
+        m_noaddressTicket = pLeash_get_default_noaddresses();
+
+        // Public IP Address
+        m_publicIPAddress = pLeash_get_default_publicip();
+
+        OnLargeIcons();
+    }
+
+    SetTimer(1, ONE_SECOND, TimerProc);
+
+    if (!CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL && !CLeashApp::m_hAfsDLL)
+    {
+        AfxMessageBox("Neither Kerberos Four, Kerberos Five nor AFS is loaded!!!"
+                   "\r\nYou will not be able to retrieve tickets and/or "
+                   "tokens.",
+                   MB_OK|MB_ICONWARNING);
+    }
+
+    if (!CLeashApp::m_hAfsDLL)
+    {
+        // No AFS installed
+        SetDlgItemText(IDC_LABEL_KERB_TICKETS,
+                       "Your Kerberos Tickets (Issued/Expires/[Renew]/Principal)");
+    } else
+    {
+        // AFS installed
+        SetDlgItemText(IDC_LABEL_KERB_TICKETS,
+                       "Your Kerberos Tickets and AFS Tokens (Issued/Expires/[Renew]/Principal)");
+
+    }
+
+    // CLeashApp::m_krbv5_context = NULL;
+}
+
+VOID CLeashView::OnInitTicket()
+{
+    try {
+        InitTicket(m_hWnd);
+    }
+    catch(...) {
+        AfxMessageBox("Ticket Getting operation already in progress", MB_OK, 0);
+    }
+}
+
+UINT CLeashView::InitTicket(void * hWnd)
+{
+#ifndef KRB5_TC_NOTICKET
+    if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock TGS request mutex");
+#endif
+    m_importedTickets = 0;
+
+    LSH_DLGINFO_EX ldi;
+    char username[64];
+    char realm[192];
+    int i=0, j=0;
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        throw("Unable to lock ticketinfo");
+    }
+
+    char * principal = ticketinfo.Krb5.principal;
+    if (!*principal)
+        principal = ticketinfo.Krb4.principal;
+    for (; principal[i] && principal[i] != '@'; i++)
+    {
+        username[i] = principal[i];
+    }
+    username[i] = '\0';
+    if (principal[i]) {
+        for (i++ ; principal[i] ; i++, j++)
+        {
+            realm[j] = principal[i];
+        }
+    }
+    realm[j] = '\0';
+    ReleaseMutex(ticketinfo.lockObj);
+
+    ldi.size = sizeof(ldi);
+    ldi.dlgtype = DLGTYPE_PASSWD;
+    ldi.title = ldi.in.title;
+    strcpy(ldi.in.title,"Initialize Ticket");
+    ldi.username = ldi.in.username;
+    strcpy(ldi.in.username,username);
+    ldi.realm = ldi.in.realm;
+    strcpy(ldi.in.realm,realm);
+    ldi.dlgtype = DLGTYPE_PASSWD;
+    ldi.use_defaults = 1;
+
+    if (!hWnd)
+    {
+        AfxMessageBox("There is a problem finding the Leash Window!",
+                   MB_OK|MB_ICONSTOP);
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        return 0;
+    }
+
+#ifndef KRB5_TC_NOTICKET
+    ReleaseMutex(m_tgsReqMutex);
+#endif
+    int result = pLeash_kinit_dlg_ex((HWND)hWnd, &ldi);
+
+    if (-1 == result)
+    {
+        AfxMessageBox("There is a problem getting tickets!",
+                   MB_OK|MB_ICONSTOP);
+    }
+    else if ( result )
+    {
+#ifndef KRB5_TC_NOTICKET
+        if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+            throw("Unable to lock TGS request mutex");
+#endif
+        if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            throw("Unable to lock ticketinfo");
+        }
+        ticketinfo.Krb4.btickets = GOOD_TICKETS;
+        m_warningOfTicketTimeLeftKrb4 = 0;
+        m_warningOfTicketTimeLeftKrb5 = 0;
+        m_ticketStatusKrb4 = 0;
+        m_ticketStatusKrb5 = 0;
+        ReleaseMutex(ticketinfo.lockObj);
+        m_autoRenewalAttempted = 0;
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        ::SendMessage((HWND)hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+    }
+    return 0;
+}
+
+VOID CLeashView::OnImportTicket()
+{
+    try {
+        ImportTicket(m_hWnd);
+    }
+    catch(...) {
+        AfxMessageBox("Ticket Getting operation already in progress", MB_OK|MB_ICONWARNING, 0);
+    }
+}
+
+UINT CLeashView::ImportTicket(void * hWnd)
+{
+    if ( !CLeashApp::m_hKrb5DLL )
+        return 0;
+
+#ifndef KRB5_TC_NOTICKET
+    if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock TGS request mutex");
+#endif
+    int import = 0;
+    int warning = 0;
+
+    krb5_error_code code;
+    krb5_ccache mslsa_ccache=0;
+    krb5_principal princ = 0;
+    char * pname = 0;
+    LONG krb5Error = 0;
+    TicketList * tlist = NULL;
+
+    if (code = pkrb5_cc_resolve(CLeashApp::m_krbv5_context, "MSLSA:", &mslsa_ccache))
+        goto cleanup;
+
+    if (code = pkrb5_cc_get_principal(CLeashApp::m_krbv5_context, mslsa_ccache, &princ))
+        goto cleanup;
+
+    if (code = pkrb5_unparse_name(CLeashApp::m_krbv5_context, princ, &pname))
+        goto cleanup;
+
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        throw("Unable to lock ticketinfo");
+    }
+    krb5Error = pLeashKRB5GetTickets( &ticketinfo.Krb5, &tlist,
+                                      &CLeashApp::m_krbv5_context);
+    if ( tlist )
+        pLeashFreeTicketList(&tlist);
+
+    warning = strcmp(ticketinfo.Krb5.principal, pname) && ticketinfo.Krb5.btickets;
+    ReleaseMutex(ticketinfo.lockObj);
+
+  cleanup:
+    if (pname)
+        pkrb5_free_unparsed_name(CLeashApp::m_krbv5_context, pname);
+
+    if (princ)
+        pkrb5_free_principal(CLeashApp::m_krbv5_context, princ);
+
+    if (mslsa_ccache)
+        pkrb5_cc_close(CLeashApp::m_krbv5_context, mslsa_ccache);
+
+    if ( code == 0 ) {
+        if (warning)
+        {
+            INT whatToDo;
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            if (!CLeashApp::m_hAfsDLL || !CLeashApp::m_hKrb4DLL)
+                whatToDo = AfxMessageBox("You are about to replace your existing ticket(s)\n"
+                                          "with a ticket imported from the Windows credential cache!",
+                                          MB_OKCANCEL, 0);
+            else
+                whatToDo = AfxMessageBox("You are about to replace your existing ticket(s)/token(s)"
+                                          "with ticket imported from the Windows credential cache!",
+                                          MB_OKCANCEL, 0);
+#ifndef KRB5_TC_NOTICKET
+            if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+                throw("Unable to lock tgsReqMutex");
+#endif
+            if (whatToDo == IDOK)
+            {
+                pLeash_kdestroy();
+                import = 1;
+            }
+        } else {
+            import = 1;
+        }
+
+        if ( import ) {
+            int result = pLeash_import();
+            if (-1 == result)
+            {
+#ifndef KRB5_TC_NOTICKET
+                ReleaseMutex(m_tgsReqMutex);
+#endif
+                AfxMessageBox("There is a problem importing tickets!",
+                               MB_OK|MB_ICONSTOP);
+                ::SendMessage((HWND)hWnd,WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+                m_importedTickets = 0;
+            }
+            else
+            {
+                if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+                    ReleaseMutex(m_tgsReqMutex);
+#endif
+                    throw("Unable to lock ticketinfo");
+                }
+                ticketinfo.Krb4.btickets = GOOD_TICKETS;
+                ticketinfo.Krb5.btickets = GOOD_TICKETS;
+                m_warningOfTicketTimeLeftKrb4 = 0;
+                m_warningOfTicketTimeLeftKrb5 = 0;
+                m_ticketStatusKrb4 = 0;
+                m_ticketStatusKrb5 = 0;
+                ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+                ReleaseMutex(m_tgsReqMutex);
+#endif
+                ::SendMessage((HWND)hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+
+#ifndef KRB5_TC_NOTICKET
+                if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+                    throw("Unable to lock tgsReqMutex");
+#endif
+                if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+                    ReleaseMutex(m_tgsReqMutex);
+#endif
+                    throw("Unable to lock ticketinfo");
+                }
+#ifndef KRB5_TC_NOTICKET
+                ReleaseMutex(m_tgsReqMutex);
+#endif
+
+                if (ticketinfo.Krb5.btickets != GOOD_TICKETS) {
+                    ReleaseMutex(ticketinfo.lockObj);
+                    AfxBeginThread(InitTicket,hWnd);
+                } else {
+                    ReleaseMutex(ticketinfo.lockObj);
+                    m_importedTickets = 1;
+                    m_autoRenewalAttempted = 0;
+                }
+            }
+        }
+#ifndef KRB5_TC_NOTICKET
+        else {
+            ReleaseMutex(m_tgsReqMutex);
+        }
+#endif
+    }
+#ifndef KRB5_TC_NOTICKET
+    else {
+        ReleaseMutex(m_tgsReqMutex);
+    }
+#endif
+    return 0;
+}
+
+VOID CLeashView::OnRenewTicket()
+{
+    if ( !CLeashApp::m_hKrb5DLL )
+        return;
+
+    try {
+        RenewTicket(m_hWnd);
+    }
+    catch(...) {
+        AfxMessageBox("Ticket Getting operation already in progress", MB_OK|MB_ICONWARNING, 0);
+    }
+}
+
+UINT CLeashView::RenewTicket(void * hWnd)
+{
+    if ( !CLeashApp::m_hKrb5DLL )
+        return 0;
+
+#ifndef KRB5_TC_NOTICKET
+    if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock TGS request mutex");
+#endif
+
+    // Try to renew
+    BOOL b_renewed = pLeash_renew();
+    TicketList * tlist = NULL;
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) {
+#ifndef KRB5_TC_NOTICKET
+        ReleaseMutex(m_tgsReqMutex);
+#endif
+        throw("Unable to lock ticketinfo");
+    }
+    LONG krb5Error = pLeashKRB5GetTickets(&ticketinfo.Krb5, &tlist,
+                                           &CLeashApp::m_krbv5_context);
+    pLeashFreeTicketList(&tlist);
+    if ( b_renewed ) {
+        if (!krb5Error && ticketinfo.Krb5.btickets == GOOD_TICKETS) {
+            ticketinfo.Krb4.btickets = GOOD_TICKETS;
+            m_warningOfTicketTimeLeftKrb4 = 0;
+            m_warningOfTicketTimeLeftKrb5 = 0;
+            m_ticketStatusKrb4 = 0;
+            m_ticketStatusKrb5 = 0;
+            m_autoRenewalAttempted = 0;
+            ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            ::SendMessage((HWND)hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+            return 0;
+        }
+    }
+
+    krb5_error_code code;
+    krb5_ccache mslsa_ccache=0;
+    krb5_principal princ = 0;
+    char * pname = 0;
+
+    if (code = pkrb5_cc_resolve(CLeashApp::m_krbv5_context, "MSLSA:", &mslsa_ccache))
+        goto cleanup;
+
+    if (code = pkrb5_cc_get_principal(CLeashApp::m_krbv5_context, mslsa_ccache, &princ))
+        goto cleanup;
+
+    if (code = pkrb5_unparse_name(CLeashApp::m_krbv5_context, princ, &pname))
+        goto cleanup;
+
+    if ( !strcmp(ticketinfo.Krb5.principal, pname) )
+        m_importedTickets = 1;
+
+  cleanup:
+    ReleaseMutex(ticketinfo.lockObj);
+
+    if (pname)
+        pkrb5_free_unparsed_name(CLeashApp::m_krbv5_context, pname);
+
+    if (princ)
+        pkrb5_free_principal(CLeashApp::m_krbv5_context, princ);
+
+    if (mslsa_ccache)
+        pkrb5_cc_close(CLeashApp::m_krbv5_context, mslsa_ccache);
+
+#ifndef KRB5_TC_NOTICKET
+    ReleaseMutex(m_tgsReqMutex);
+#endif
+    // If imported from Kerberos LSA, re-import
+    // Otherwise, init the tickets
+    if ( m_importedTickets )
+        AfxBeginThread(ImportTicket,hWnd);
+    else
+        AfxBeginThread(InitTicket,hWnd);
+
+    return 0;
+}
+
+VOID CLeashView::OnDestroyTicket()
+{
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+    BOOL b_destroy =ticketinfo.Krb4.btickets || ticketinfo.Krb5.btickets || ticketinfo.Afs.btickets;
+    ReleaseMutex(ticketinfo.lockObj);
+
+    if (b_destroy)
+    {
+        INT whatToDo;
+
+        if (!CLeashApp::m_hAfsDLL)
+            whatToDo = AfxMessageBox("You are about to destroy your ticket(s)!",
+                                     MB_OKCANCEL, 0);
+        else
+            whatToDo = AfxMessageBox("You are about to destroy your ticket(s)/token(s)!",
+                                     MB_OKCANCEL, 0);
+
+        if (whatToDo == IDOK)
+        {
+            pLeash_kdestroy();
+            ResetTreeNodes();
+            SendMessage(WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+        }
+    }
+    m_importedTickets = 0;
+    m_autoRenewalAttempted = 0;
+}
+
+VOID CLeashView::OnChangePassword()
+{
+    if (!m_hWnd)
+    {
+        AfxMessageBox("There is a problem finding the Leash Window!",
+                   MB_OK|MB_ICONSTOP);
+        return;
+    }
+
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+
+    LSH_DLGINFO_EX ldi;
+    char username[64];
+    char realm[192];
+    char * principal = ticketinfo.Krb5.principal;
+    if (!*principal)
+       principal = ticketinfo.Krb4.principal;
+    int i=0, j=0;
+    for (; principal[i] && principal[i] != '@'; i++)
+    {
+       username[i] = principal[i];
+    }
+    username[i] = '\0';
+    if (principal[i]) {
+       for (i++ ; principal[i] ; i++, j++)
+       {
+           realm[j] = principal[i];
+       }
+    }
+    realm[j] = '\0';
+    ReleaseMutex(ticketinfo.lockObj);
+
+    ldi.size = sizeof(ldi);
+    ldi.dlgtype = DLGTYPE_CHPASSWD;
+    ldi.title = ldi.in.title;
+    strcpy(ldi.in.title,"Change Password");
+    ldi.username = ldi.in.username;
+    strcpy(ldi.in.username,username);
+    ldi.realm = ldi.in.realm;
+    strcpy(ldi.in.realm,realm);
+    ldi.use_defaults = 1;
+
+    int result = pLeash_changepwd_dlg_ex(m_hWnd, &ldi);
+    if (-1 == result)
+    {
+        AfxMessageBox("There is a problem changing password!",
+                   MB_OK|MB_ICONSTOP);
+    }
+}
+
+VOID CLeashView::OnUpdateDisplay()
+{
+    BOOL AfsEnabled = m_pApp->GetProfileInt("Settings", "AfsStatus", 1);
+
+    m_pTree = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
+    if (!m_pTree)
+    {
+        AfxMessageBox("There is a problem finding the Ticket Tree!",
+                    MB_OK|MB_ICONSTOP);
+        return;
+    }
+
+    m_pImageList = &m_imageList;
+    if (!m_pImageList)
+    {
+        AfxMessageBox("There is a problem finding images for the Ticket Tree!",
+                   MB_OK|MB_ICONSTOP);
+        return;
+    }
+
+    m_pTree->SetImageList(&m_imageList, TVSIL_NORMAL);
+
+    TV_INSERTSTRUCT m_tvinsert;
+
+    INT ticketIconStatusKrb4;
+    INT ticketIconStatus_SelectedKrb4;
+    INT iconStatusKrb4;
+
+    INT ticketIconStatusKrb5;
+    INT ticketIconStatus_SelectedKrb5;
+    INT iconStatusKrb5;
+
+    INT ticketIconStatusAfs;
+    INT ticketIconStatus_SelectedAfs;
+    INT iconStatusAfs;
+
+    LONG krb4Error;
+    LONG krb5Error;
+    LONG afsError;
+
+    if (WaitForSingleObject( ticketinfo.lockObj, 100 ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+
+    // Get Kerb 4 tickets in list
+    krb4Error = pLeashKRB4GetTickets(&ticketinfo.Krb4, &m_listKrb4);
+
+    // Get Kerb 5 tickets in list
+    krb5Error = pLeashKRB5GetTickets(&ticketinfo.Krb5, &m_listKrb5,
+                                     &CLeashApp::m_krbv5_context);
+    if (!krb5Error || krb5Error == KRB5_FCC_NOFILE)
+    {
+        if (CLeashApp::m_hKrb5DLL && !CLeashApp::m_krbv5_profile)
+        {
+            CHAR confname[MAX_PATH];
+            if (CLeashApp::GetProfileFile(confname, sizeof(confname)))
+            {
+                AfxMessageBox("Can't locate Kerberos Five Config. file!",
+                           MB_OK|MB_ICONSTOP);
+            }
+
+            const char *filenames[2];
+            filenames[0] = confname;
+            filenames[1] = NULL;
+            pprofile_init(filenames, &CLeashApp::m_krbv5_profile);
+        }
+    }
+
+    // Get AFS Tokens in list
+    if (CLeashApp::m_hAfsDLL) {
+        char * principal;
+        if ( ticketinfo.Krb5.principal[0] )
+            principal = ticketinfo.Krb5.principal;
+        else if ( ticketinfo.Krb4.principal[0] )
+            principal = ticketinfo.Krb4.principal;
+        else
+            principal = "";
+        afsError = pLeashAFSGetToken(&ticketinfo.Afs, &m_listAfs, principal);
+    }
+
+    /*
+     * Update Ticket Status for Krb4 and Krb5 so that we may use their state
+     * to select the appropriate Icon for the Parent Node
+     */
+
+    /* Krb4 */
+    UpdateTicketTime(ticketinfo.Krb4);
+    m_ticketStatusKrb4 = GetLowTicketStatus(4);
+    if (!m_listKrb4 || EXPIRED_TICKETS == ticketinfo.Krb4.btickets ||
+         m_ticketStatusKrb4 == ZERO_MINUTES_LEFT)
+    {
+        ticketIconStatusKrb4 = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedKrb4 = EXPIRED_CLOCK;
+        iconStatusKrb4 = EXPIRED_TICKET;
+    }
+    else if (TICKETS_LOW == ticketinfo.Krb4.btickets ||
+             m_ticketStatusKrb4 == FIVE_MINUTES_LEFT ||
+             m_ticketStatusKrb4 == TEN_MINUTES_LEFT ||
+             m_ticketStatusKrb4 == FIFTEEN_MINUTES_LEFT)
+    {
+        ticketIconStatusKrb4 = LOW_CLOCK;
+        ticketIconStatus_SelectedKrb4 = LOW_CLOCK;
+        iconStatusKrb4 = LOW_TICKET;
+    }
+    else if ( CLeashApp::m_hKrb4DLL )
+    {
+        ticketIconStatusKrb4 = ACTIVE_CLOCK;
+        ticketIconStatus_SelectedKrb4 = ACTIVE_CLOCK;
+        iconStatusKrb4 = ACTIVE_TICKET;
+    } else {
+        ticketIconStatusKrb4 = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedKrb4 = EXPIRED_CLOCK;
+        iconStatusKrb4 = TICKET_NOT_INSTALLED;
+    }
+
+    /* Krb5 */
+    UpdateTicketTime(ticketinfo.Krb5);
+    m_ticketStatusKrb5 = GetLowTicketStatus(5);
+    if (!m_listKrb5 || EXPIRED_TICKETS == ticketinfo.Krb5.btickets ||
+         m_ticketStatusKrb5 == ZERO_MINUTES_LEFT)
+    {
+        ticketIconStatusKrb5 = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedKrb5 = EXPIRED_CLOCK;
+        iconStatusKrb5 = EXPIRED_TICKET;
+    }
+    else if (TICKETS_LOW == ticketinfo.Krb5.btickets ||
+             m_ticketStatusKrb5 == FIVE_MINUTES_LEFT ||
+             m_ticketStatusKrb5 == TEN_MINUTES_LEFT ||
+             m_ticketStatusKrb5 == FIFTEEN_MINUTES_LEFT)
+    {
+        ticketIconStatusKrb5 = LOW_CLOCK;
+        ticketIconStatus_SelectedKrb5 = LOW_CLOCK;
+        iconStatusKrb5 = LOW_TICKET;
+    }
+    else if ( CLeashApp::m_hKrb5DLL )
+    {
+        ticketIconStatusKrb5 = ACTIVE_CLOCK;
+        ticketIconStatus_SelectedKrb5 = ACTIVE_CLOCK;
+        iconStatusKrb5 = ACTIVE_TICKET;
+    } else
+    {
+        ticketIconStatusKrb5 = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedKrb5 = EXPIRED_CLOCK;
+        iconStatusKrb5 = TICKET_NOT_INSTALLED;
+    }
+
+    /* Afs */
+    UpdateTicketTime(ticketinfo.Afs);
+    m_ticketStatusAfs = GetLowTicketStatus(1);
+    if (!m_listAfs || EXPIRED_TICKETS == ticketinfo.Afs.btickets ||
+         m_ticketStatusAfs == ZERO_MINUTES_LEFT)
+    {
+        ticketIconStatusAfs = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedAfs = EXPIRED_CLOCK;
+        iconStatusAfs = EXPIRED_TICKET;
+    }
+    else if (TICKETS_LOW == ticketinfo.Afs.btickets ||
+             m_ticketStatusAfs == FIVE_MINUTES_LEFT ||
+             m_ticketStatusAfs == TEN_MINUTES_LEFT ||
+             m_ticketStatusAfs == FIFTEEN_MINUTES_LEFT)
+    {
+        ticketIconStatusAfs = LOW_CLOCK;
+        ticketIconStatus_SelectedAfs = LOW_CLOCK;
+        iconStatusAfs = LOW_TICKET;
+    }
+    else if ( CLeashApp::m_hAfsDLL )
+    {
+        ticketIconStatusAfs = ACTIVE_CLOCK;
+        ticketIconStatus_SelectedAfs = ACTIVE_CLOCK;
+        iconStatusAfs = ACTIVE_TICKET;
+    } else
+    {
+        ticketIconStatusAfs = EXPIRED_CLOCK;
+        ticketIconStatus_SelectedAfs = EXPIRED_CLOCK;
+        iconStatusAfs = TICKET_NOT_INSTALLED;
+    }
+
+    // Tree Structure common values
+    m_pTree->DeleteAllItems();
+
+    m_tvinsert.hParent = NULL;
+    m_tvinsert.hInsertAfter = TVI_LAST;
+    m_tvinsert.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
+    m_tvinsert.item.hItem = NULL;
+    m_tvinsert.item.state = 0;
+    m_tvinsert.item.stateMask = 0; //TVIS_EXPANDED;
+    m_tvinsert.item.cchTextMax = 6;
+
+    if (CLeashApp::m_hKrb5DLL && m_listKrb5) {
+        m_tvinsert.item.pszText = ticketinfo.Krb5.principal;
+        switch ( iconStatusKrb5 ) {
+        case ACTIVE_TICKET:
+            m_tvinsert.item.iSelectedImage = ACTIVE_PARENT_NODE;
+            break;
+        case LOW_TICKET:
+            m_tvinsert.item.iSelectedImage = LOW_PARENT_NODE;
+            break;
+        case EXPIRED_TICKET:
+            m_tvinsert.item.iSelectedImage = EXPIRED_PARENT_NODE;
+            break;
+        }
+    } else if (CLeashApp::m_hKrb4DLL && m_listKrb4) {
+        m_tvinsert.item.pszText = ticketinfo.Krb4.principal;
+        switch ( iconStatusKrb4 ) {
+        case ACTIVE_TICKET:
+            m_tvinsert.item.iSelectedImage = ACTIVE_PARENT_NODE;
+            break;
+        case LOW_TICKET:
+            m_tvinsert.item.iSelectedImage = LOW_PARENT_NODE;
+            break;
+        case EXPIRED_TICKET:
+            m_tvinsert.item.iSelectedImage = EXPIRED_PARENT_NODE;
+            break;
+        }
+    } else {
+        m_tvinsert.item.iSelectedImage = NONE_PARENT_NODE;
+    }
+    m_tvinsert.item.iImage = m_tvinsert.item.iSelectedImage;
+    m_tvinsert.item.cChildren = 0;
+    m_tvinsert.item.lParam = 0;
+    m_tvinsert.hParent = NULL;
+    m_hPrincipal = m_pTree->InsertItem(&m_tvinsert);
+
+    SetTrayIcon(NIM_MODIFY, m_tvinsert.item.iImage);
+
+    // Krb5
+    m_tvinsert.hParent = m_hPrincipal;
+
+    if (CLeashApp::m_hKrb5DLL)
+    {
+        // kerb5 installed
+        m_tvinsert.item.pszText = "Kerberos Five Tickets";
+        m_tvinsert.item.iImage = iconStatusKrb5;
+        m_tvinsert.item.iSelectedImage = iconStatusKrb5;
+    }
+    else
+    {
+        // kerb5 not installed
+        ticketinfo.Krb5.btickets = NO_TICKETS;
+        m_tvinsert.item.pszText = "Kerberos Five Tickets (Not Available)";
+        m_tvinsert.item.iImage = TICKET_NOT_INSTALLED;
+        m_tvinsert.item.iSelectedImage = TICKET_NOT_INSTALLED;
+    }
+
+    m_hKerb5 = m_pTree->InsertItem(&m_tvinsert);
+
+    TicketList* tempList = m_listKrb5, *killList;
+    while (tempList)
+    {
+        m_tvinsert.hParent = m_hKerb5;
+        m_tvinsert.item.iImage = ticketIconStatusKrb5;
+        m_tvinsert.item.iSelectedImage = ticketIconStatus_SelectedKrb5;
+        m_tvinsert.item.pszText = tempList->theTicket;
+        m_hk5tkt = m_pTree->InsertItem(&m_tvinsert);
+
+        if ( tempList->tktEncType ) {
+            m_tvinsert.hParent = m_hk5tkt;
+            m_tvinsert.item.iImage = TKT_ENCRYPTION;
+            m_tvinsert.item.iSelectedImage = TKT_ENCRYPTION;
+            m_tvinsert.item.pszText = tempList->tktEncType;
+            m_pTree->InsertItem(&m_tvinsert);
+        }
+        if ( tempList->keyEncType ) {
+            m_tvinsert.hParent = m_hk5tkt;
+            m_tvinsert.item.iImage = TKT_SESSION;
+            m_tvinsert.item.iSelectedImage = TKT_SESSION;
+            m_tvinsert.item.pszText = tempList->keyEncType;
+            m_pTree->InsertItem(&m_tvinsert);
+        }
+
+        if ( tempList->addrCount && tempList->addrList ) {
+            for ( int n=0; n<tempList->addrCount; n++ ) {
+                m_tvinsert.hParent = m_hk5tkt;
+                m_tvinsert.item.iImage = TKT_ADDRESS;
+                m_tvinsert.item.iSelectedImage = TKT_ADDRESS;
+                m_tvinsert.item.pszText = tempList->addrList[n];
+                m_pTree->InsertItem(&m_tvinsert);
+            }
+        }
+        tempList = tempList->next;
+    }
+
+    pLeashFreeTicketList(&m_listKrb5);
+
+    if (m_hKerb5State == NODE_IS_EXPANDED)
+        m_pTree->Expand(m_hKerb5, TVE_EXPAND);
+
+    // Krb4
+    m_tvinsert.hParent = m_hPrincipal;
+
+    if (CLeashApp::m_hKrb4DLL)
+    {
+        m_tvinsert.item.pszText = "Kerberos Four Tickets";
+        m_tvinsert.item.iImage = iconStatusKrb4;
+        m_tvinsert.item.iSelectedImage = iconStatusKrb4;
+    }
+    else
+    {
+        ticketinfo.Krb4.btickets = NO_TICKETS;
+        m_tvinsert.item.pszText = "Kerberos Four Tickets (Not Available)";
+        m_tvinsert.item.iImage = TICKET_NOT_INSTALLED;
+        m_tvinsert.item.iSelectedImage = TICKET_NOT_INSTALLED;
+    }
+
+    m_hKerb4 = m_pTree ->InsertItem(&m_tvinsert);
+
+    if (m_hPrincipalState == NODE_IS_EXPANDED)
+        m_pTree->Expand(m_hPrincipal, TVE_EXPAND);
+
+    m_tvinsert.hParent = m_hKerb4;
+    m_tvinsert.item.iImage = ticketIconStatusKrb4;
+    m_tvinsert.item.iSelectedImage = ticketIconStatus_SelectedKrb4;
+
+    tempList = m_listKrb4, *killList;
+    while (tempList)
+    {
+        m_tvinsert.item.pszText = tempList->theTicket;
+        m_pTree->InsertItem(&m_tvinsert);
+        tempList = tempList->next;
+    }
+
+    pLeashFreeTicketList(&m_listKrb4);
+
+    if (m_hKerb4State == NODE_IS_EXPANDED)
+        m_pTree->Expand(m_hKerb4, TVE_EXPAND);
+
+
+    // AFS
+    m_tvinsert.hParent = m_hPrincipal;
+
+    if (!CLeashApp::m_hAfsDLL)
+    { // AFS service not started or just no tickets
+        m_tvinsert.item.pszText = "AFS Tokens (Not Available)";
+        m_tvinsert.item.iImage = TICKET_NOT_INSTALLED;
+        m_tvinsert.item.iSelectedImage = TICKET_NOT_INSTALLED;
+    }
+
+    if (!afsError && CLeashApp::m_hAfsDLL && m_tvinsert.item.pszText)
+    { // AFS installed
+
+        if (AfsEnabled)
+        {
+            m_tvinsert.item.pszText = "AFS Tokens";
+            m_tvinsert.item.iImage = iconStatusAfs;
+            m_tvinsert.item.iSelectedImage = iconStatusAfs;
+        }
+       else
+        {
+            m_tvinsert.item.pszText = "AFS Tokens (Disabled)";
+            m_tvinsert.item.iImage = TICKET_NOT_INSTALLED;
+            m_tvinsert.item.iSelectedImage = TICKET_NOT_INSTALLED;
+        }
+
+        m_hAFS = m_pTree->InsertItem(&m_tvinsert);
+
+        m_tvinsert.hParent = m_hAFS;
+        m_tvinsert.item.iImage = ticketIconStatusAfs;
+        m_tvinsert.item.iSelectedImage = ticketIconStatus_SelectedAfs;
+
+        tempList = m_listAfs, *killList;
+        while (tempList)
+        {
+            m_tvinsert.item.pszText = tempList->theTicket;
+            m_pTree->InsertItem(&m_tvinsert);
+            tempList = tempList->next;
+        }
+
+        pLeashFreeTicketList(&m_listAfs);
+
+        if (m_hAFSState == NODE_IS_EXPANDED)
+            m_pTree->Expand(m_hAFS, TVE_EXPAND);
+    }
+    else if (!afsError && CLeashApp::m_hAfsDLL && !m_tvinsert.item.pszText)
+    {
+        m_tvinsert.item.pszText = "AFS Tokens";
+        m_tvinsert.item.iImage = EXPIRED_TICKET;;
+        m_tvinsert.item.iSelectedImage = EXPIRED_TICKET;
+    }
+
+    if (m_startup)
+    {
+        //m_startup = FALSE;
+        UpdateTicketTime(ticketinfo.Krb4);
+    }
+
+    CString sPrincipal = ticketinfo.Krb5.principal;
+    if (sPrincipal.IsEmpty())
+        sPrincipal = ticketinfo.Krb4.principal;
+
+       // if no tickets
+       if (!ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets)
+               sPrincipal = " No Tickets ";
+
+       // if no tickets and tokens
+    if (!ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets && !ticketinfo.Afs.btickets) //&& sPrincipal.IsEmpty())
+    {
+        // No tickets
+        m_pTree->DeleteAllItems();
+
+        m_tvinsert.hParent = NULL;
+        m_tvinsert.item.pszText = " No Tickets/Tokens ";
+        m_tvinsert.item.iImage = NONE_PARENT_NODE;
+        m_tvinsert.item.iSelectedImage = NONE_PARENT_NODE;
+        m_hPrincipal = m_pTree->InsertItem(&m_tvinsert);
+
+        if (CMainFrame::m_wndToolBar)
+        {
+            CToolBarCtrl *_toolBar = NULL;
+            CToolBarCtrl& toolBar = CMainFrame::m_wndToolBar.GetToolBarCtrl();
+            _toolBar = &toolBar;
+            if (_toolBar)
+            {
+                toolBar.SetState(ID_DESTROY_TICKET, TBSTATE_INDETERMINATE);
+            }
+            else
+            {
+                AfxMessageBox("There is a problem with the Leash Toolbar!",
+                           MB_OK|MB_ICONSTOP);
+            }
+        }
+    }
+    else
+    {
+        // We have some tickets
+        m_pTree->SetItemText(m_hPrincipal, sPrincipal);
+
+        if (CMainFrame::m_wndToolBar)
+        {
+            CToolBarCtrl *_toolBar = NULL;
+            CToolBarCtrl& toolBar = CMainFrame::m_wndToolBar.GetToolBarCtrl();
+            _toolBar = &toolBar;
+            if (_toolBar)
+            {
+                toolBar.SetState(ID_DESTROY_TICKET, TBSTATE_ENABLED);
+            }
+            else
+            {
+                AfxMessageBox("There is a problem with the Leash Toolbar!", MB_OK|MB_ICONSTOP);
+            }
+        }
+    }
+    ReleaseMutex(ticketinfo.lockObj);
+}
+
+VOID CLeashView::OnSynTime()
+{
+    LONG returnValue;
+    returnValue = pLeash_timesync(1);
+}
+
+VOID CLeashView::OnActivateView(BOOL bActivate, CView* pActivateView,
+                                CView* pDeactiveView)
+{
+    UINT check = NULL;
+
+    if (m_alreadyPlayed)
+    {
+        CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
+        return;
+    }
+
+    // The following code has put here because at the time
+    // 'checking and unchecking' a menuitem with the
+    // 'OnUpdate.....(CCmdUI* pCmdUI) functions' were unreliable
+    // in CLeashView -->> Better done in CMainFrame
+    if( CLeashApp::m_hProgram != 0 )
+    {
+        m_hMenu = ::GetMenu(CLeashApp::m_hProgram);
+    } else {
+        return;
+    }
+    if( m_hMenu == NULL )
+    {
+        AfxMessageBox("There is a problem finding the Leash main menu!",
+                   MB_OK|MB_ICONSTOP);
+        return;
+    }
+    if (!m_largeIcons)
+        check = CheckMenuItem(m_hMenu, ID_LARGE_ICONS, MF_CHECKED);
+    else
+        check = CheckMenuItem(m_hMenu, ID_LARGE_ICONS, MF_UNCHECKED);
+
+    if( check != MF_CHECKED || check != MF_UNCHECKED )
+    {
+        m_debugStartUp = 1;
+    }
+
+    if (!m_destroyTicketsOnExit)
+        check = CheckMenuItem(m_hMenu, ID_KILL_TIX_ONEXIT, MF_UNCHECKED);
+    else
+        check = CheckMenuItem(m_hMenu, ID_KILL_TIX_ONEXIT, MF_CHECKED);
+
+    if (!m_upperCaseRealm)
+        check = CheckMenuItem(m_hMenu, ID_UPPERCASE_REALM, MF_UNCHECKED);
+    else
+        check = CheckMenuItem(m_hMenu, ID_UPPERCASE_REALM, MF_CHECKED);
+
+    if (!m_lowTicketAlarm)
+    {
+        m_lowTicketAlarmSound = FALSE;
+
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_LOW_TICKET_ALARM, MF_UNCHECKED);
+    }
+    else
+    {
+        m_lowTicketAlarmSound = TRUE;
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_LOW_TICKET_ALARM, MF_CHECKED);
+    }
+
+    if (!m_autoRenewTickets)
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_AUTO_RENEW, MF_UNCHECKED);
+    }
+    else
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_AUTO_RENEW, MF_CHECKED);
+    }
+
+    m_debugWindow = m_pApp->GetProfileInt("Settings", "DebugWindow", 0);
+    if (!m_debugWindow)
+        check = CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_UNCHECKED);
+    else
+        check = CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_CHECKED);
+
+    m_alreadyPlayed = TRUE;
+    if (m_pApp)
+    {
+        m_debugWindow = m_pApp->GetProfileInt("Settings", "DebugWindow", 0);
+
+        if (m_hMenu)
+        {
+            if (!m_debugWindow)
+            {
+                CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_UNCHECKED);
+            }
+            else
+            {
+                CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_CHECKED);
+            }
+        }
+    }
+    else
+    {
+        ApplicationInfoMissingMsg();
+    }
+
+    m_alreadyPlayed = TRUE;
+
+    if (!CKrbProperties::KrbPropertiesOn)
+        SendMessage(WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+
+    if (m_debugStartUp)
+    {
+        OnDebugMode();
+    }
+
+    m_debugStartUp = FALSE;
+
+    CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
+}
+
+VOID CLeashView::OnDebugMode()
+{
+    if (!pset_krb_debug)
+        return;
+
+    if (!m_pDebugWindow)
+    {
+        AfxMessageBox("There is a problem with the Leash Debug Window!",
+                   MB_OK|MB_ICONSTOP);
+        return;
+    }
+
+
+    // Check all possible 'KRB' system varables, then reset (delete) debug file
+    CHAR*  Env[] = {"TEMP", "TMP", "HOME", NULL};
+    CHAR** pEnv = Env;
+    CHAR debugFilePath[MAX_PATH];
+    *debugFilePath = 0;
+
+    while (*pEnv)
+    {
+        CHAR* ptestenv = getenv(*pEnv);
+        if (ptestenv)
+        {
+            // reset debug file
+            strcpy(debugFilePath, ptestenv);
+            strcat(debugFilePath, "\\LshDebug.log");
+            remove(debugFilePath);
+            break;
+        }
+
+        pEnv++;
+    }
+
+    if (!m_debugStartUp)
+    {
+        if (m_debugWindow%2 == 0)
+            m_debugWindow = ON;
+        else
+            m_debugWindow = OFF;
+    }
+
+    if (!m_pApp)
+    {
+        ApplicationInfoMissingMsg();
+    }
+    else if (!m_debugWindow)
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_UNCHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "DebugWindow", FALSE_FLAG);
+        m_pDebugWindow->DestroyWindow();
+        pset_krb_debug(OFF);
+        pset_krb_ap_req_debug(OFF);
+        return;
+    }
+    else
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_DEBUG_MODE, MF_CHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "DebugWindow", TRUE_FLAG);
+    }
+
+    // Creates the Debug dialog if not created already
+    if (m_pDebugWindow->GetSafeHwnd() == 0)
+    { // displays the Debug Window
+        m_pDebugWindow->Create(debugFilePath);
+    }
+}
+
+VOID CLeashView::OnLargeIcons()
+{
+    INT x, y, n;
+
+    if (change_icon_size)
+    {
+        if (m_largeIcons%2 == 0)
+            m_largeIcons = ON;
+        else
+            m_largeIcons = OFF;
+    }
+    else
+    {
+        if (m_largeIcons%2 == 0)
+            m_largeIcons = OFF;
+        else
+            m_largeIcons = ON;
+    }
+
+    x = y = SMALL_ICONS;
+
+    if (!m_pApp)
+        ApplicationInfoMissingMsg();
+    else
+    {
+        if (!m_largeIcons)
+        {
+            if (m_hMenu)
+                CheckMenuItem(m_hMenu, ID_LARGE_ICONS, MF_CHECKED);
+
+            x = y = LARGE_ICONS;
+
+           if (!m_startup)
+           {
+                m_pApp->WriteProfileInt("Settings", "LargeIcons", TRUE_FLAG);
+           }
+        }
+        else
+        {
+            if (m_hMenu)
+                CheckMenuItem(m_hMenu, ID_LARGE_ICONS, MF_UNCHECKED);
+
+            x = y = SMALL_ICONS;
+
+            if (!m_startup)
+            {
+                m_pApp->WriteProfileInt("Settings", "LargeIcons", FALSE_FLAG);
+            }
+        }
+    }
+
+    HICON hIcon[IMAGE_COUNT];
+    for (n = 0; n < IMAGE_COUNT; n++)
+    {
+        hIcon[n] = NULL;
+    }
+
+    m_imageList.DeleteImageList( );
+
+    UINT bitsPerPixel = GetDeviceCaps( ::GetDC(::GetDesktopWindow()), BITSPIXEL);
+    UINT ilcColor;
+    if ( bitsPerPixel >= 32 )
+        ilcColor = ILC_COLOR32;
+    else if ( bitsPerPixel >= 24 )
+        ilcColor = ILC_COLOR24;
+    else if ( bitsPerPixel >= 16 )
+        ilcColor = ILC_COLOR16;
+    else if ( bitsPerPixel >= 8 )
+        ilcColor = ILC_COLOR8;
+    else
+        ilcColor = ILC_COLOR;
+    m_imageList.Create(x, y, ilcColor | ILC_MASK, IMAGE_COUNT, 1);
+    m_imageList.SetBkColor(GetSysColor(COLOR_WINDOW));
+
+    hIcon[ACTIVE_TRAY_ICON] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_GOOD);
+    hIcon[LOW_TRAY_ICON] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_LOW);
+    hIcon[EXPIRED_TRAY_ICON] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_EXPIRED);
+    hIcon[NONE_TRAY_ICON]  = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_NONE);
+    hIcon[ACTIVE_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_PRINCIPAL_GOOD);
+    hIcon[LOW_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_PRINCIPAL_LOW);
+    hIcon[EXPIRED_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_PRINCIPAL_EXPIRED);
+    hIcon[NONE_PARENT_NODE]  = AfxGetApp()->LoadIcon(IDI_LEASH_PRINCIPAL_NONE);
+    hIcon[ACTIVE_TICKET] = AfxGetApp()->LoadIcon(IDI_TICKETTYPE_GOOD);
+    hIcon[LOW_TICKET] = AfxGetApp()->LoadIcon(IDI_TICKETTYPE_LOW);
+    hIcon[EXPIRED_TICKET] = AfxGetApp()->LoadIcon(IDI_TICKETTYPE_EXPIRED);
+    hIcon[TICKET_NOT_INSTALLED] = AfxGetApp()->LoadIcon(IDI_TICKETTYPE_NOTINSTALLED);
+    hIcon[ACTIVE_CLOCK] = AfxGetApp()->LoadIcon(IDI_TICKET_GOOD);
+    hIcon[LOW_CLOCK] = AfxGetApp()->LoadIcon(IDI_TICKET_LOW);
+    hIcon[EXPIRED_CLOCK] = AfxGetApp()->LoadIcon(IDI_TICKET_EXPIRED);
+    hIcon[TKT_ADDRESS] = AfxGetApp()->LoadIcon(IDI_LEASH_TICKET_ADDRESS);
+    hIcon[TKT_SESSION] = AfxGetApp()->LoadIcon(IDI_LEASH_TICKET_SESSION);
+    hIcon[TKT_ENCRYPTION] = AfxGetApp()->LoadIcon(IDI_LEASH_TICKET_ENCRYPTION);
+
+    for (n = 0; n < IMAGE_COUNT; n++)
+    {
+        if ( !hIcon[n] ) {
+            AfxMessageBox("Can't find one or more images in the Leash Ticket Tree!",
+                        MB_OK|MB_ICONSTOP);
+            return;
+        }
+        m_imageList.Add(hIcon[n]);
+    }
+
+    m_pTree = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
+    m_pTree->SetItemHeight(y+2);
+
+    if (!m_startup)
+        SendMessage(WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+}
+
+VOID CLeashView::OnKillTixOnExit()
+{
+    if (m_destroyTicketsOnExit%2 == 0)
+        m_destroyTicketsOnExit = ON;
+    else
+        m_destroyTicketsOnExit = OFF;
+
+    if (m_pApp)
+    {
+        if (!m_destroyTicketsOnExit)
+        {
+            if (m_hMenu)
+                CheckMenuItem(m_hMenu, ID_KILL_TIX_ONEXIT, MF_UNCHECKED);
+
+            AfxMessageBox("Tickets will be not be destroyed upon exiting Leash!!!",
+                       MB_OK|MB_ICONWARNING);
+            m_pApp->WriteProfileInt("Settings", "DestroyTicketsOnExit",
+                                    FALSE_FLAG);
+        }
+        else
+        {
+            if (m_hMenu)
+                CheckMenuItem(m_hMenu, ID_KILL_TIX_ONEXIT, MF_CHECKED);
+
+            AfxMessageBox("All tickets/tokens will be destroyed upon exiting Leash!!!",
+                       MB_OK|MB_ICONWARNING);
+            m_pApp->WriteProfileInt("Settings", "DestroyTicketsOnExit", TRUE_FLAG);
+        }
+    }
+    else
+    {
+        ApplicationInfoMissingMsg();
+    }
+}
+
+VOID CLeashView::OnUppercaseRealm()
+{
+    if (m_upperCaseRealm%2 == 0)
+        m_upperCaseRealm = ON;
+    else
+        m_upperCaseRealm = OFF;
+
+    if (!m_pApp)
+    {
+        ApplicationInfoMissingMsg();
+    }
+    else if (!m_upperCaseRealm)
+    {
+        pLeash_set_default_uppercaserealm(FALSE_FLAG);
+
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_UPPERCASE_REALM, MF_UNCHECKED);
+    }
+    else
+    {
+        pLeash_set_default_uppercaserealm(TRUE_FLAG);
+
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_UPPERCASE_REALM, MF_CHECKED);
+    }
+}
+
+VOID CLeashView::ResetTreeNodes()
+{
+    m_hPrincipalState = 0;
+    m_hKerb4State = 0;
+    m_hKerb5State = 0;
+    m_hAFSState = 0;
+}
+
+VOID CLeashView::OnDestroy()
+{
+    SetTrayIcon(NIM_DELETE);
+
+    CFormView::OnDestroy();
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+    BOOL b_destroy = m_destroyTicketsOnExit && (ticketinfo.Krb4.btickets || ticketinfo.Krb5.btickets);
+    ReleaseMutex(ticketinfo.lockObj);
+
+    if (b_destroy)
+    {
+        if (pLeash_kdestroy())
+        {
+            AfxMessageBox("There is a problem destroying tickets!",
+                       MB_OK|MB_ICONSTOP);
+        }
+    }
+}
+
+VOID CLeashView::OnUpdateDestroyTicket(CCmdUI* pCmdUI)
+{
+    if (!CLeashApp::m_hAfsDLL)
+        pCmdUI->SetText("&Destroy Ticket(s)\tCtrl+D");
+    else
+        pCmdUI->SetText("&Destroy Ticket(s)/Token(s)\tCtrl+D");
+
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+    BOOL b_enable =!ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets && !ticketinfo.Afs.btickets;
+    ReleaseMutex(ticketinfo.lockObj);
+
+    if (b_enable)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+}
+
+VOID CLeashView::OnUpdateInitTicket(CCmdUI* pCmdUI)
+{
+    if (!CLeashApp::m_hAfsDLL)
+        pCmdUI->SetText("&Get Ticket(s)\tCtrl+T");
+    else
+        pCmdUI->SetText("&Get Ticket(s)/Token(s)\tCtrl+T");
+
+    if (!CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL &&
+        !CLeashApp::m_hAfsDLL)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+}
+
+VOID CLeashView::OnUpdateRenewTicket(CCmdUI* pCmdUI)
+{
+    if (!CLeashApp::m_hAfsDLL)
+        pCmdUI->SetText("&Renew Ticket(s)\tCtrl+R");
+    else
+        pCmdUI->SetText("&Renew Ticket(s)/Token(s)\tCtrl+R");
+
+    if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock ticketinfo");
+    BOOL b_enable = !(ticketinfo.Krb4.btickets || ticketinfo.Krb5.btickets) ||
+                    !CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL && !CLeashApp::m_hAfsDLL;
+    ReleaseMutex(ticketinfo.lockObj);
+
+    if (b_enable)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+}
+
+VOID CLeashView::OnUpdateImportTicket(CCmdUI* pCmdUI)
+{
+    bool ccIsMSLSA = false;
+
+#ifndef KRB5_TC_NOTICKET
+    if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+        throw("Unable to lock TGS request mutex");
+#endif
+    if (CLeashApp::m_krbv5_context)
+    {
+        const char *ccName = pkrb5_cc_default_name(CLeashApp::m_krbv5_context);
+
+        if (ccName)
+            ccIsMSLSA = !strcmp(ccName, "MSLSA:");
+    }
+
+    if (!CLeashApp::m_hKrbLSA || !pLeash_importable() || ccIsMSLSA)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+#ifndef KRB5_TC_NOTICKET
+    ReleaseMutex(m_tgsReqMutex);
+#endif
+}
+
+LRESULT CLeashView::OnGoodbye(WPARAM wParam, LPARAM lParam)
+{
+    m_pDebugWindow->DestroyWindow();
+    return 0L;
+}
+
+VOID CLeashView::OnLeashRestore()
+{
+    if ( CMainFrame::m_isMinimum ) {
+        CMainFrame * frame = (CMainFrame *)GetParentFrame();
+        frame->ShowTaskBarButton(TRUE);
+        frame->ShowWindow(SW_SHOWNORMAL);
+    }
+}
+
+VOID CLeashView::OnLeashMinimize()
+{
+    if ( !CMainFrame::m_isMinimum ) {
+        CMainFrame * frame = (CMainFrame *)GetParentFrame();
+        // frame->ShowTaskBarButton(FALSE);
+        frame->ShowWindow(SW_HIDE);
+        frame->ShowWindow(SW_MINIMIZE);
+    }
+}
+
+LRESULT CLeashView::OnTrayIcon(WPARAM wParam, LPARAM lParam)
+{
+    switch ( lParam ) {
+    case WM_LBUTTONDOWN:
+        if ( CMainFrame::m_isMinimum )
+            OnLeashRestore();
+        else
+            OnLeashMinimize();
+        break;
+    case WM_RBUTTONDOWN:
+        {
+            int nFlags;
+            CMenu * menu = new CMenu();
+            menu->CreatePopupMenu();
+            if ( !CMainFrame::m_isMinimum )
+                menu->AppendMenu(MF_STRING, ID_LEASH_MINIMIZE, "&Close Leash Window");
+            else
+                menu->AppendMenu(MF_STRING, ID_LEASH_RESTORE, "&Open Leash Window");
+            menu->AppendMenu(MF_SEPARATOR);
+            menu->AppendMenu(MF_STRING, ID_INIT_TICKET, "&Get Tickets");
+#ifndef KRB5_TC_NOTICKET
+            if (WaitForSingleObject( m_tgsReqMutex, INFINITE ) != WAIT_OBJECT_0)
+                throw("Unable to lock TGS request mutex");
+#endif
+            if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0)
+                throw("Unable to lock ticketinfo");
+            if (!(ticketinfo.Krb4.btickets || ticketinfo.Krb5.btickets) ||
+                 !CLeashApp::m_hKrb4DLL && !CLeashApp::m_hKrb5DLL &&
+                 !CLeashApp::m_hAfsDLL)
+                nFlags = MF_STRING | MF_GRAYED;
+            else
+                nFlags = MF_STRING;
+            menu->AppendMenu(nFlags, ID_RENEW_TICKET, "&Renew Tickets");
+            if (!CLeashApp::m_hKrbLSA || !pLeash_importable())
+                nFlags = MF_STRING | MF_GRAYED;
+            else
+                nFlags = MF_STRING;
+            menu->AppendMenu(MF_STRING, ID_IMPORT_TICKET, "&Import Tickets");
+            if (!ticketinfo.Krb4.btickets && !ticketinfo.Krb5.btickets && !ticketinfo.Afs.btickets)
+                nFlags = MF_STRING | MF_GRAYED;
+            else
+                nFlags = MF_STRING;
+            ReleaseMutex(ticketinfo.lockObj);
+#ifndef KRB5_TC_NOTICKET
+            ReleaseMutex(m_tgsReqMutex);
+#endif
+            menu->AppendMenu(MF_STRING, ID_DESTROY_TICKET, "&Destroy Tickets");
+            menu->AppendMenu(MF_STRING, ID_CHANGE_PASSWORD, "&Change Password");
+
+            menu->AppendMenu(MF_SEPARATOR);
+            if ( m_autoRenewTickets )
+                nFlags = MF_STRING | MF_CHECKED;
+            else
+                nFlags = MF_STRING | MF_UNCHECKED;
+            menu->AppendMenu(nFlags, ID_AUTO_RENEW, "&Automatic Ticket Renewal");
+            if ( m_lowTicketAlarm )
+                nFlags = MF_STRING | MF_CHECKED;
+            else
+                nFlags = MF_STRING | MF_UNCHECKED;
+            menu->AppendMenu(nFlags, ID_LOW_TICKET_ALARM, "&Expiration Alarm");
+            menu->AppendMenu(MF_SEPARATOR);
+            menu->AppendMenu(MF_STRING, ID_APP_EXIT, "E&xit");
+            menu->SetDefaultItem(ID_LEASH_RESTORE);
+
+            POINT pt;
+            GetCursorPos(&pt);
+
+           SetForegroundWindow();
+            menu->TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON,
+                                pt.x, pt.y, GetParentFrame());
+           PostMessage(WM_NULL, 0, 0);
+            menu->DestroyMenu();
+            delete menu;
+        }
+        break;
+    case WM_MOUSEMOVE:
+        // SendMessage(WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+        break;
+    }
+    return 0L;
+}
+
+VOID CLeashView::OnAppAbout()
+{
+    CLeashAboutBox leashAboutBox;
+    leashAboutBox.DoModal();
+}
+
+
+VOID CLeashView::OnAfsControlPanel()
+{
+    CAfsProperties afsProperties;
+    afsProperties.DoModal();
+}
+
+VOID CLeashView::OnInitialUpdate()
+{
+    CFormView::OnInitialUpdate();
+    CLeashApp::m_hProgram = ::FindWindow(_T("LEASH.0WNDCLASS"), NULL);
+    EnableToolTips();
+}
+
+VOID CLeashView::OnItemexpandedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
+{
+    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
+
+    if (m_hPrincipal == pNMTreeView->itemNew.hItem)
+        m_hPrincipalState = pNMTreeView->action;
+    else if (m_hKerb4 == pNMTreeView->itemNew.hItem)
+        m_hKerb4State = pNMTreeView->action;
+    else if (m_hKerb5 == pNMTreeView->itemNew.hItem)
+        m_hKerb5State = pNMTreeView->action;
+    else if (m_hAFS ==  pNMTreeView->itemNew.hItem)
+        m_hAFSState =  pNMTreeView->action;
+
+    CMainFrame::m_isBeingResized = TRUE;
+    *pResult = 0;
+}
+
+VOID CLeashView::OnUpdateDebugMode(CCmdUI* pCmdUI)
+{
+    if (!pset_krb_debug)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+}
+
+VOID CLeashView::OnUpdateCfgFiles(CCmdUI* pCmdUI)
+{
+    if (!pkrb_get_krbconf2)
+        pCmdUI->Enable(FALSE);
+    else
+        pCmdUI->Enable(TRUE);
+}
+
+VOID CLeashView::OnLeashProperties()
+{
+    CLeashProperties leashProperties;
+    leashProperties.DoModal();
+}
+
+VOID CLeashView::OnKrbProperties()
+{
+    CKrbProperties krbProperties("Kerberos Properties");
+    krbProperties.DoModal();
+}
+
+VOID CLeashView::OnKrb4Properties()
+{
+    CKrb4Properties krb4Properties("Kerberos Four Properties");
+    krb4Properties.DoModal();
+}
+
+VOID CLeashView::OnKrb5Properties()
+{
+    CKrb5Properties krb5Properties("Kerberos Five Properties");
+    krb5Properties.DoModal();
+}
+
+/*
+void CLeashView::GetRowWidthHeight(CDC* pDC, LPCSTR theString, int& nRowWidth,
+                                   int& nRowHeight, int& nCharWidth)
+{
+    TEXTMETRIC tm;
+
+    //CEx29aDoc* pDoc = GetDocument();
+       pDC->GetTextMetrics(&tm);
+    nCharWidth = tm.tmAveCharWidth + 1;
+    nRowWidth = strlen(theString);
+
+    //int nFields = theString.GetLength();
+
+    //for(int i = 0; i < nFields; i++)
+    //{
+       //    nRowWidth += nCharWidth;
+       //}
+
+    nRowWidth *= nCharWidth;
+    nRowHeight = tm.tmHeight;
+}
+*/
+
+void CLeashView::SetTrayText(int nim, CString tip)
+{
+    if ( (nim == NIM_MODIFY) && (m_bIconDeleted) )
+        return;
+    if ( (nim == NIM_MODIFY) && (!m_bIconAdded) )
+        nim = NIM_ADD;
+
+    if ( (nim != NIM_DELETE) || IsWindow(m_hWnd) )
+    {
+        NOTIFYICONDATA nid;
+        memset (&nid, 0x00, sizeof(NOTIFYICONDATA));
+        nid.cbSize = sizeof(NOTIFYICONDATA);
+        nid.hWnd = m_hWnd;
+        nid.uID = 0;
+        nid.uFlags = NIF_MESSAGE | NIF_TIP;
+        nid.uCallbackMessage = WM_TRAYICON;
+        strncpy(nid.szTip, (LPCTSTR) tip, sizeof(nid.szTip));
+        nid.szTip[sizeof(nid.szTip)-1] = '\0';
+        Shell_NotifyIcon (nim, &nid);
+    }
+
+    if ( nim == NIM_ADD )
+        m_bIconAdded = TRUE;
+    if ( nim == NIM_DELETE )
+        m_bIconDeleted = TRUE;
+}
+
+void CLeashView::SetTrayIcon(int nim, int state)
+{
+    static HICON hIcon[IMAGE_COUNT];
+    static BOOL bIconInit = FALSE;
+
+    if ( (nim == NIM_MODIFY) && (m_bIconDeleted) )
+        return;
+    if ( (nim == NIM_MODIFY) && (!m_bIconAdded) )
+        nim = NIM_ADD;
+
+    if ( (nim != NIM_DELETE) || IsWindow(m_hWnd) )
+    {
+        if ( !bIconInit ) {
+            // The state is reported as the parent node value although
+            // we want to use the Tray Version of the icons
+            hIcon[ACTIVE_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_GOOD);
+            hIcon[LOW_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_LOW);
+            hIcon[EXPIRED_PARENT_NODE] = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_EXPIRED);
+            hIcon[NONE_PARENT_NODE]  = AfxGetApp()->LoadIcon(IDI_LEASH_TRAY_NONE);
+            bIconInit = TRUE;
+        }
+
+        NOTIFYICONDATA nid;
+        memset (&nid, 0x00, sizeof(NOTIFYICONDATA));
+        nid.cbSize = sizeof(NOTIFYICONDATA);
+        nid.hWnd = m_hWnd;
+        nid.uID = 0;
+        nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+        nid.uCallbackMessage = WM_TRAYICON;
+        nid.hIcon = hIcon[state];
+        Shell_NotifyIcon (nim, &nid);
+    }
+
+    if ( nim == NIM_ADD )
+        m_bIconAdded = TRUE;
+    if ( nim == NIM_DELETE )
+        m_bIconDeleted = TRUE;
+}
+
+BOOL CLeashView::PreTranslateMessage(MSG* pMsg)
+{
+       if ( pMsg->message == ID_OBTAIN_TGT_WITH_LPARAM )
+       {
+               OutputDebugString("Obtain TGT with LParam\n");
+       }
+
+    if ( pMsg->message == WM_TIMER ) {
+        try {
+        if (InterlockedDecrement(&m_timerMsgNotInProgress) == 0) {
+
+            CString ticketStatusKrb4 = TCHAR(NOT_INSTALLED);
+            CString ticketStatusKrb5 = TCHAR(NOT_INSTALLED);
+            CString ticketStatusAfs  = TCHAR(NOT_INSTALLED);
+            CString strTimeDate;
+            CString lowTicketWarningKrb4;
+            CString lowTicketWarningKrb5;
+            CString lowTicketWarningAfs;
+
+          timer_start:
+            if (WaitForSingleObject( ticketinfo.lockObj, 100 ) != WAIT_OBJECT_0)
+                throw("Unable to lock ticketinfo");
+            if (CLeashApp::m_hKrb5DLL)
+            {
+                // KRB5
+                UpdateTicketTime(ticketinfo.Krb5);
+
+                if (!ticketinfo.Krb5.btickets)
+                {
+                    ticketStatusKrb5 = "Kerb-5: No Tickets";
+                }
+                else if (EXPIRED_TICKETS == ticketinfo.Krb5.btickets)
+                {
+                    ticketStatusKrb5 = "Kerb-5: Expired Ticket(s)";
+                    m_ticketTimeLeft = 0;
+                    lowTicketWarningKrb5 = "Your Kerberos Five ticket(s) have expired";
+                    if (!m_warningOfTicketTimeLeftLockKrb5)
+                        m_warningOfTicketTimeLeftKrb5 = 0;
+                    m_warningOfTicketTimeLeftLockKrb5 = ZERO_MINUTES_LEFT;
+                }
+                else
+                {
+                    m_ticketStatusKrb5 = GetLowTicketStatus(5);
+                    switch (m_ticketStatusKrb5)
+                    {
+                    case TWENTY_MINUTES_LEFT:
+                        break;
+                    case FIFTEEN_MINUTES_LEFT:
+                        ticketinfo.Krb5.btickets = TICKETS_LOW;
+                        lowTicketWarningKrb5 = "Less then 15 minutes left on your Kerberos Five ticket(s)";
+                        break;
+                    case TEN_MINUTES_LEFT:
+                        ticketinfo.Krb5.btickets = TICKETS_LOW;
+                        lowTicketWarningKrb5 = "Less then 10 minutes left on your Kerberos Five ticket(s)";
+                        if (!m_warningOfTicketTimeLeftLockKrb5)
+                            m_warningOfTicketTimeLeftKrb5 = 0;
+                        m_warningOfTicketTimeLeftLockKrb5 = TEN_MINUTES_LEFT;
+                        break;
+                    case FIVE_MINUTES_LEFT:
+                        ticketinfo.Krb5.btickets = TICKETS_LOW;
+                        if (m_warningOfTicketTimeLeftLockKrb5 == TEN_MINUTES_LEFT)
+                            m_warningOfTicketTimeLeftKrb5 = 0;
+                        m_warningOfTicketTimeLeftLockKrb5 = FIVE_MINUTES_LEFT;
+                        lowTicketWarningKrb5 = "Less then 5 minutes left on your Kerberos Five ticket(s)";
+                        break;
+                    default:
+                        m_ticketStatusKrb5 = 0;
+                        break;
+                    }
+                }
+
+                if (CMainFrame::m_isMinimum)
+                {
+                    // minimized dispay
+                    ticketStatusKrb5.Format("Kerb-5: %02d:%02d Left",
+                                             (m_ticketTimeLeft / 60L / 60L),
+                                             (m_ticketTimeLeft / 60L % 60L));
+                }
+                else
+                {
+                    // normal display
+                    if (GOOD_TICKETS == ticketinfo.Krb5.btickets || TICKETS_LOW == ticketinfo.Krb5.btickets)
+                    {
+                        if ( m_ticketTimeLeft >= 60 ) {
+                            ticketStatusKrb5.Format("Kerb-5 Ticket Life: %02d:%02d",
+                                                     (m_ticketTimeLeft / 60L / 60L),
+                                                     (m_ticketTimeLeft / 60L % 60L));
+                        } else {
+                            ticketStatusKrb5.Format("Kerb-5 Ticket Life: < 1 min");
+                        }
+                    }
+
+                    if (CMainFrame::m_wndStatusBar)
+                    {
+                        CMainFrame::m_wndStatusBar.SetPaneInfo(1, 111112, SBPS_NORMAL, 130);
+                        CMainFrame::m_wndStatusBar.SetPaneText(1, ticketStatusKrb5, SBT_POPOUT);
+                    }
+                }
+            }
+            else
+            {
+                // not installed
+                ticketStatusKrb5.Format("Kerb-5: Not Available");
+
+                if (CMainFrame::m_wndStatusBar)
+                {
+                    CMainFrame::m_wndStatusBar.SetPaneInfo(1, 111112, SBPS_NORMAL, 130);
+                    CMainFrame::m_wndStatusBar.SetPaneText(1, ticketStatusKrb5, SBT_POPOUT);
+                }
+            }
+            //KRB5
+
+            if (CLeashApp::m_hKrb4DLL)
+            {
+                // KRB4
+                UpdateTicketTime(ticketinfo.Krb4);
+                if (!ticketinfo.Krb4.btickets)
+                {
+                    ticketStatusKrb4 = "Kerb-4: No Tickets";
+                }
+                else if (EXPIRED_TICKETS == ticketinfo.Krb4.btickets)
+                {
+#ifndef NO_KRB5
+                    if (ticketinfo.Krb5.btickets &&
+                         EXPIRED_TICKETS != ticketinfo.Krb5.btickets &&
+                         m_autoRenewTickets &&
+                         !m_autoRenewalAttempted &&
+                         ticketinfo.Krb5.renew_till &&
+                         (ticketinfo.Krb5.issue_date + ticketinfo.Krb5.renew_till -LeashTime() > 20 * 60) &&
+                         pLeash_get_default_use_krb4()
+                         )
+                    {
+                        m_autoRenewalAttempted = 1;
+                        ReleaseMutex(ticketinfo.lockObj);
+                        AfxBeginThread(RenewTicket,m_hWnd);
+                        goto timer_start;
+                    }
+#endif /* NO_KRB5 */
+                    ticketStatusKrb4 = "Kerb-4: Expired Tickets";
+                    lowTicketWarningKrb4 = "Your Kerberos Four ticket(s) have expired";
+                    if (!m_warningOfTicketTimeLeftLockKrb4)
+                        m_warningOfTicketTimeLeftKrb4 = 0;
+                    m_warningOfTicketTimeLeftLockKrb4 = ZERO_MINUTES_LEFT;
+                    m_ticketTimeLeft = 0;
+                }
+                else if ( pLeash_get_default_use_krb4() )
+                {
+                    m_ticketStatusKrb4 = GetLowTicketStatus(4);
+                    switch (m_ticketStatusKrb4)
+                    {
+                    case FIFTEEN_MINUTES_LEFT:
+                        ticketinfo.Krb4.btickets = TICKETS_LOW;
+                        lowTicketWarningKrb4 = "Less then 15 minutes left on your Kerberos Four ticket(s)";
+                        break;
+                    case TEN_MINUTES_LEFT:
+                        ticketinfo.Krb4.btickets = TICKETS_LOW;
+                        lowTicketWarningKrb4 = "Less then 10 minutes left on your Kerberos Four ticket(s)";
+                        if (!m_warningOfTicketTimeLeftLockKrb4)
+                            m_warningOfTicketTimeLeftKrb4 = 0;
+                        m_warningOfTicketTimeLeftLockKrb4 = TEN_MINUTES_LEFT;
+                        break;
+                    case FIVE_MINUTES_LEFT:
+                        ticketinfo.Krb4.btickets = TICKETS_LOW;
+                        if (m_warningOfTicketTimeLeftLockKrb4 == TEN_MINUTES_LEFT)
+                            m_warningOfTicketTimeLeftKrb4 = 0;
+                        m_warningOfTicketTimeLeftLockKrb4 = FIVE_MINUTES_LEFT;
+                        lowTicketWarningKrb4 = "Less then 5 minutes left on your Kerberos Four ticket(s)";
+                        break;
+                    default:
+                        m_ticketStatusKrb4 = 0;
+                        break;
+                    }
+
+                }
+
+                if (CMainFrame::m_isMinimum)
+                {
+                    // minimized dispay
+                    ticketStatusKrb4.Format("Kerb-4: %02d:%02d Left",
+                                             (m_ticketTimeLeft / 60L / 60L),
+                                             (m_ticketTimeLeft / 60L % 60L));
+                }
+                else
+                {
+                    // normal display
+                    if (GOOD_TICKETS == ticketinfo.Krb4.btickets ||
+                         TICKETS_LOW == ticketinfo.Krb4.btickets)
+                    {
+                        if ( m_ticketTimeLeft >= 60 ) {
+                            ticketStatusKrb4.Format("Kerb-4 Ticket Life: %02d:%02d",
+                                                     (m_ticketTimeLeft / 60L / 60L),
+                                                     (m_ticketTimeLeft / 60L % 60L));
+                        } else {
+                            ticketStatusKrb4.Format("Kerb-4 Ticket Life: < 1 min");
+                        }
+                    }
+
+                    if (CMainFrame::m_wndStatusBar)
+                    {
+                        CMainFrame::m_wndStatusBar.SetPaneInfo(2, 111111, SBPS_NORMAL, 130);
+                        CMainFrame::m_wndStatusBar.SetPaneText(2, ticketStatusKrb4, SBT_POPOUT);
+                    }
+                }
+            }
+            else
+            {
+                // not installed
+                ticketStatusKrb4.Format("Kerb-4: Not Available");
+
+                if (CMainFrame::m_wndStatusBar)
+                {
+                    CMainFrame::m_wndStatusBar.SetPaneInfo(2, 111111, SBPS_NORMAL, 130);
+                    CMainFrame::m_wndStatusBar.SetPaneText(2, ticketStatusKrb4, SBT_POPOUT);
+                }
+            }
+            // KRB4
+
+            if (CLeashApp::m_hAfsDLL)
+            {
+                // AFS
+                UpdateTicketTime(ticketinfo.Afs);
+                if (!ticketinfo.Afs.btickets)
+                {
+                    BOOL AfsEnabled = m_pApp->GetProfileInt("Settings", "AfsStatus", 1);
+                    if ( AfsEnabled )
+                        ticketStatusAfs = "AFS: No Tickets";
+                    else
+                        ticketStatusAfs = "AFS: Disabled";
+                }
+                else if (EXPIRED_TICKETS == ticketinfo.Afs.btickets)
+                {
+#ifndef NO_KRB5
+                    if (ticketinfo.Krb5.btickets &&
+                         EXPIRED_TICKETS != ticketinfo.Krb5.btickets &&
+                         m_autoRenewTickets &&
+                         !m_autoRenewalAttempted &&
+                         ticketinfo.Krb5.renew_till &&
+                         (ticketinfo.Krb5.issue_date + ticketinfo.Krb5.renew_till -LeashTime() > 20 * 60) &&
+                         !stricmp(ticketinfo.Krb5.principal,ticketinfo.Afs.principal)
+                         )
+                    {
+                        m_autoRenewalAttempted = 1;
+                        ReleaseMutex(ticketinfo.lockObj);
+                        AfxBeginThread(RenewTicket,m_hWnd);
+                        goto timer_start;
+                    }
+#endif /* NO_KRB5 */
+                    ticketStatusAfs = "AFS: Expired Tickets";
+                    lowTicketWarningAfs = "Your AFS token(s) have expired";
+                    if (!m_warningOfTicketTimeLeftLockAfs)
+                        m_warningOfTicketTimeLeftAfs = 0;
+                    m_warningOfTicketTimeLeftLockAfs = ZERO_MINUTES_LEFT;
+                    m_ticketTimeLeft = 0;
+                }
+                else
+                {
+                    m_ticketStatusAfs = GetLowTicketStatus(1);
+                    switch (m_ticketStatusAfs)
+                    {
+                    case FIFTEEN_MINUTES_LEFT:
+                        ticketinfo.Afs.btickets = TICKETS_LOW;
+
+                        lowTicketWarningAfs = "Less then 15 minutes left on your AFStoken(s)";
+                        break;
+                    case TEN_MINUTES_LEFT:
+                        ticketinfo.Afs.btickets = TICKETS_LOW;
+
+                        lowTicketWarningAfs = "Less then 10 minutes left on your AFS token(s)";
+
+                        if (!m_warningOfTicketTimeLeftLockAfs)
+                            m_warningOfTicketTimeLeftAfs = 0;
+
+                        m_warningOfTicketTimeLeftLockAfs = TEN_MINUTES_LEFT;
+                        break;
+                    case FIVE_MINUTES_LEFT:
+                        ticketinfo.Afs.btickets = TICKETS_LOW;
+                        if (m_warningOfTicketTimeLeftLockAfs == TEN_MINUTES_LEFT)
+                            m_warningOfTicketTimeLeftAfs = 0;
+
+                        m_warningOfTicketTimeLeftLockAfs = FIVE_MINUTES_LEFT;
+
+                        lowTicketWarningAfs = "Less then 5 minutes left on your AFS token(s)";
+                        break;
+                    default:
+                        m_ticketStatusAfs = 0;
+                        break;
+                    }
+
+                }
+
+                if (CMainFrame::m_isMinimum)
+                {
+                    // minimized dispay
+                    ticketStatusAfs.Format("AFS: %02d:%02d Left",
+                                            (m_ticketTimeLeft / 60L / 60L),
+                                            (m_ticketTimeLeft / 60L % 60L));
+                }
+                else
+                {
+                    // normal display
+                    if (GOOD_TICKETS == ticketinfo.Afs.btickets ||
+                         TICKETS_LOW == ticketinfo.Afs.btickets)
+                    {
+                        if ( m_ticketTimeLeft >= 60 ) {
+                            ticketStatusAfs.Format("AFS Token Life: %02d:%02d",
+                                                    (m_ticketTimeLeft / 60L / 60L),
+                                                    (m_ticketTimeLeft / 60L % 60L));
+                        } else {
+                            ticketStatusAfs.Format("AFS Token Life: < 1 min");
+                        }
+                    }
+
+                    if (CMainFrame::m_wndStatusBar)
+                    {
+                        CMainFrame::m_wndStatusBar.SetPaneInfo(3, 111113, SBPS_NORMAL, 130);
+                        CMainFrame::m_wndStatusBar.SetPaneText(3, ticketStatusAfs, SBT_POPOUT);
+                    }
+                }
+            }
+#ifdef COMMENT
+            // we do not set this field because the field does not exist when AfsDLL is NULL
+            else
+            {
+                // not installed
+                ticketStatusAfs.Format("AFS: Not Available");
+
+                if (CMainFrame::m_wndStatusBar)
+                {
+                    CMainFrame::m_wndStatusBar.SetPaneInfo(3, 111113, SBPS_NORMAL, 130);
+                    CMainFrame::m_wndStatusBar.SetPaneText(3, ticketStatusAfs, SBT_POPOUT);
+                }
+            }
+#endif /* COMMENT */
+            // AFS
+
+#ifndef NO_KRB5
+            if ( m_ticketStatusKrb5 == TWENTY_MINUTES_LEFT &&
+                 m_autoRenewTickets && !m_autoRenewalAttempted && ticketinfo.Krb5.renew_till &&
+                 (ticketinfo.Krb5.issue_date + ticketinfo.Krb5.renew_till - LeashTime() > 20 * 60))
+            {
+                m_autoRenewalAttempted = 1;
+                ReleaseMutex(ticketinfo.lockObj);
+                AfxBeginThread(RenewTicket,m_hWnd);
+                goto timer_start;
+            }
+#endif /* NO_KRB5 */
+
+            BOOL warningKrb5 = m_ticketStatusKrb5 > NO_TICKETS &&
+                m_ticketStatusKrb5 < TWENTY_MINUTES_LEFT &&
+                    !m_warningOfTicketTimeLeftKrb5;
+            BOOL warningKrb4 = m_ticketStatusKrb4 > NO_TICKETS &&
+                m_ticketStatusKrb4 < TWENTY_MINUTES_LEFT &&
+                    !m_warningOfTicketTimeLeftKrb4;
+            BOOL warningAfs = m_ticketStatusAfs > NO_TICKETS &&
+                m_ticketStatusAfs < TWENTY_MINUTES_LEFT &&
+                    !m_warningOfTicketTimeLeftAfs;
+
+            // Play warning message only once per each case statement above
+            if (warningKrb4 || warningKrb5 || warningAfs)
+            {
+
+                CString lowTicketWarning = "";
+                int warnings = 0;
+
+                if (warningKrb5) {
+                    lowTicketWarning += lowTicketWarningKrb5;
+                    m_warningOfTicketTimeLeftKrb5 = ON;
+                    warnings++;
+                }
+                if (warningKrb4) {
+                    if ( warnings )
+                        lowTicketWarning += "\n";
+                    lowTicketWarning += lowTicketWarningKrb4;
+                    m_warningOfTicketTimeLeftKrb4 = ON;
+                    warnings++;
+                }
+                if (warningAfs) {
+                    if ( warnings )
+                        lowTicketWarning += "\n";
+                    lowTicketWarning += lowTicketWarningAfs;
+                    m_warningOfTicketTimeLeftAfs = ON;
+                    warnings++;
+                }
+
+                ReleaseMutex(ticketinfo.lockObj);
+                AlarmBeep();
+                CLeashMessageBox leashMessageBox(!CMainFrame::m_isMinimum ? GetDesktopWindow() : NULL,
+                                                  lowTicketWarning, 100000);
+                leashMessageBox.DoModal();
+                if (WaitForSingleObject( ticketinfo.lockObj, 100 ) != WAIT_OBJECT_0)
+                    throw("Unable to lock ticketinfo");
+            }
+
+            CTime tTimeDate = CTime::GetCurrentTime();
+
+            if (CMainFrame::m_isMinimum)
+            {
+                if ( CLeashApp::m_hAfsDLL )
+                    strTimeDate = ( "Leash - "
+                                    "[" + ticketStatusKrb5 + "] - " +
+                                    "[" + ticketStatusKrb4 + "] - " +
+                                    "[" + ticketStatusAfs + "] - " +
+                                    "[" + ticketinfo.Krb5.principal + "]" + " - " +
+                                    tTimeDate.Format("%A, %B %d, %Y  %H:%M "));
+                else
+                    strTimeDate = ( "Leash - "
+                                    "[" + ticketStatusKrb5 + "] - " +
+                                    "[" + ticketStatusKrb4 + "] - " +
+                                    "[" + ticketinfo.Krb5.principal + "]" + " - " +
+                                    tTimeDate.Format("%A, %B %d, %Y  %H:%M "));
+            }
+            else
+            {
+                strTimeDate = ("Leash - " +
+                                tTimeDate.Format("%A, %B %d, %Y  %H:%M ")
+                                //timeDate.Format("%d %b %y %H:%M:%S - ")
+                                );
+            }
+            ::SetWindowText(CLeashApp::m_hProgram, strTimeDate);
+
+            if (CLeashApp::m_hKrb5DLL) {
+                if ( ticketinfo.Krb5.btickets )
+                    strTimeDate = ( "Leash: "
+                                    "[" + ticketStatusKrb5 + "]" +
+                                    " - [" + ticketinfo.Krb5.principal + "]");
+                else
+                    strTimeDate = "Leash: Kerb-5 No Tickets";
+            } else {
+                if ( ticketinfo.Krb4.btickets )
+                    strTimeDate = ( "Leash: "
+                                    "[" + ticketStatusKrb4 + "]" +
+                                    " - [" + ticketinfo.Krb4.principal + "]");
+                else
+                    strTimeDate = "Leash: Kerb-4 No Tickets";
+            }
+            ReleaseMutex(ticketinfo.lockObj);
+
+            SetTrayText(NIM_MODIFY, strTimeDate);
+
+            m_updateDisplayCount++;
+            m_alreadyPlayedDisplayCount++;
+        }
+        } catch (...) {
+        }
+        InterlockedIncrement(&m_timerMsgNotInProgress);
+    }  // WM_TIMER
+
+
+    if (UPDATE_DISPLAY_TIME == m_updateDisplayCount)
+    {
+        m_updateDisplayCount = 0;
+        SendMessage(WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+    }
+
+    if (m_alreadyPlayedDisplayCount > 2)
+    {
+        m_alreadyPlayedDisplayCount = 0;
+        m_alreadyPlayed = FALSE;
+    }
+
+    if (CMainFrame::m_isBeingResized)
+    {
+        WINDOWPLACEMENT headingWndpl;
+        headingWndpl.length = sizeof(WINDOWPLACEMENT);
+
+        CWnd *heading = GetDlgItem(IDC_LABEL_KERB_TICKETS);
+        if (!heading->GetWindowPlacement(&headingWndpl))
+        {
+            AfxMessageBox("There is a problem getting Leash Heading size!",
+                       MB_OK|MB_ICONSTOP);
+            return CFormView::PreTranslateMessage(pMsg);;
+         }
+
+        m_pTree = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
+        VERIFY(m_pTree);
+        if (!m_pTree)
+        {
+            AfxMessageBox("There is a problem finding the Ticket Tree!",
+                       MB_OK|MB_ICONSTOP);
+            return CFormView::PreTranslateMessage(pMsg);
+        }
+
+        CRect rect;
+        GetClientRect(&rect);
+
+        WINDOWPLACEMENT wndpl;
+        wndpl.length = sizeof(WINDOWPLACEMENT);
+
+        if (!GetWindowPlacement(&wndpl))
+        {
+            AfxMessageBox("There is a problem getting Leash Window size!",
+                       MB_OK|MB_ICONSTOP);
+            return CFormView::PreTranslateMessage(pMsg);
+        }
+
+
+        wndpl.rcNormalPosition.top = rect.top + headingWndpl.rcNormalPosition.bottom;
+        wndpl.rcNormalPosition.right = rect.right;
+        wndpl.rcNormalPosition.bottom = rect.bottom;
+
+        m_startup = FALSE;
+
+        if (!m_pTree->SetWindowPlacement(&wndpl))
+        {
+            AfxMessageBox("There is a problem setting Leash ticket Tree size!",
+                       MB_OK|MB_ICONSTOP);
+        }
+
+
+        UpdateWindow();
+
+#ifdef COOL_SCROLL
+        // The follow code creates a cool scroll bar on the MainFrame
+           m_pTree = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
+           CWnd *pLabel = GetDlgItem(IDC_LABEL_KERB_TICKETS);
+
+           VERIFY(m_pTree);
+
+           // Sync Tree Frame with Main Frame
+           // WINDOWPLACEMENT wndpl;
+           WINDOWPLACEMENT wndplTree;
+           WINDOWPLACEMENT wndplLabel;
+           wndpl.length = sizeof(WINDOWPLACEMENT);
+           wndplTree.length = sizeof(WINDOWPLACEMENT);
+           wndplLabel.length = sizeof(WINDOWPLACEMENT);
+           GetWindowPlacement(&wndpl);
+           m_pTree->GetWindowPlacement(&wndplTree);
+           pLabel->GetWindowPlacement(&wndplLabel);
+
+           if (!m_startup)
+           {
+           if (ticketinfo.Krb4.btickets || ticketinfo.Krb5.btickets)
+           { // control scroll bars to TreeView
+           #define TICKET_LABEL_TOP 8
+           #define TICKET_LABEL_BOTTOM 28
+           #define TICKET_LABEL_RIGHT 398
+           #define RIGHT_FRAME_ADJUSTMENT 13
+           #define BOTTOM_FRAME_ADJUSTMENT 72
+           #define STRETCH_FACTOR 3
+
+           char theText[MAX_K_NAME_SZ+40];
+           int longestLine = 0;
+           int theHeight = 0;
+           BOOL disableScrollHorz = FALSE;
+           BOOL disableScrollVert = FALSE;
+           RECT rect;
+
+           HTREEITEM  xTree;
+           TV_ITEM item;
+           item.mask = TVIF_HANDLE | TVIF_TEXT;
+           item.cchTextMax = sizeof(theText);
+
+           xTree = m_hKerb4;
+           do
+           {
+           item.hItem = xTree;
+           item.pszText = theText;
+           VERIFY(m_pTree->GetItem(&item));
+
+           UINT offSet = m_pTree->GetIndent();
+           if (!m_pTree->GetItemRect(xTree, &rect, TRUE))
+           {
+           longestLine = 0;
+           theHeight = 0;
+           break;
+           }
+
+           if (rect.right > longestLine)
+           longestLine = rect.right + RIGHT_FRAME_ADJUSTMENT;
+
+           theHeight = rect.bottom + BOTTOM_FRAME_ADJUSTMENT;
+           }
+           while ((xTree = m_pTree->GetNextItem(xTree, TVGN_NEXTVISIBLE)));
+
+
+           // Horz
+           if (longestLine < wndpl.rcNormalPosition.right)
+           { // disable scroll
+           disableScrollHorz = TRUE;
+           SetScrollPos(SB_HORZ, 0, TRUE);
+           EnableScrollBar(SB_HORZ, ESB_DISABLE_BOTH);
+           }
+           else
+           { // enable scroll
+           EnableScrollBar(SB_HORZ, ESB_ENABLE_BOTH);
+           SetScrollRange(SB_HORZ, 0, longestLine , TRUE);
+           }
+
+           // Vert
+           if (theHeight < wndpl.rcNormalPosition.bottom)
+           { // disable scroll
+           disableScrollVert = TRUE;
+           SetScrollPos(SB_VERT, 0, TRUE);
+           EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH);
+           }
+           else
+           { // enable scroll
+           EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH);
+           SetScrollRange(SB_VERT, 0, theHeight, TRUE);
+           }
+
+
+           if (!disableScrollHorz)
+           {
+           wndpl.rcNormalPosition.left =
+           wndplTree.rcNormalPosition.left;
+
+           wndplLabel.rcNormalPosition.left =
+           wndpl.rcNormalPosition.left + 8;
+           }
+
+           if (!disableScrollVert)
+           {
+           wndpl.rcNormalPosition.top =
+           wndplTree.rcNormalPosition.top;
+           }
+           else
+           {
+           wndplLabel.rcNormalPosition.left =
+           wndpl.rcNormalPosition.left + 8;
+
+           wndplLabel.rcNormalPosition.top = TICKET_LABEL_TOP;
+           wndplLabel.rcNormalPosition.bottom = TICKET_LABEL_BOTTOM;
+           wndplLabel.rcNormalPosition.right = TICKET_LABEL_RIGHT;
+           }
+
+           wndpl.rcNormalPosition.right *= STRETCH_FACTOR;
+           wndpl.rcNormalPosition.bottom *= STRETCH_FACTOR;
+           }
+           }
+
+           m_startup = FALSE;
+
+           m_pTree->SetWindowPlacement(&wndpl);
+           pLabel->SetWindowPlacement(&wndplLabel);
+#endif /* COOL_SCROLL */
+
+        CMainFrame::m_isBeingResized = FALSE;
+    }
+
+       if (::IsWindow(pMsg->hwnd))
+               return CFormView::PreTranslateMessage(pMsg);
+       else
+               return FALSE;
+}
+
+VOID CLeashView::OnLowTicketAlarm()
+{
+    if (m_lowTicketAlarm%2 == 0)
+        m_lowTicketAlarm = ON;
+    else
+        m_lowTicketAlarm = OFF;
+
+
+    if (!m_pApp)
+    {
+        ApplicationInfoMissingMsg();
+    }
+    else if (!m_lowTicketAlarm)
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_LOW_TICKET_ALARM, MF_UNCHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "LowTicketAlarm", FALSE_FLAG);
+    }
+    else
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_LOW_TICKET_ALARM, MF_CHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "LowTicketAlarm", TRUE_FLAG);
+    }
+}
+
+VOID CLeashView::OnAutoRenew()
+{
+    if (m_autoRenewTickets%2 == 0)
+        m_autoRenewTickets = ON;
+    else
+        m_autoRenewTickets = OFF;
+
+
+    if (!m_pApp)
+    {
+        ApplicationInfoMissingMsg();
+    }
+    else if (!m_autoRenewTickets)
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_AUTO_RENEW, MF_UNCHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "AutoRenewTickets", FALSE_FLAG);
+        m_autoRenewTickets = FALSE;
+    }
+    else
+    {
+        if (m_hMenu)
+            CheckMenuItem(m_hMenu, ID_AUTO_RENEW, MF_CHECKED);
+
+        m_pApp->WriteProfileInt("Settings", "AutoRenewTickets", TRUE_FLAG);
+        m_autoRenewTickets = TRUE;
+    }
+    m_autoRenewalAttempted = 0;
+}
+
+VOID CLeashView::AlarmBeep()
+{
+       if (m_lowTicketAlarmSound)
+       {
+               ::Beep(2000, 200);
+               ::Beep(200, 200);
+               ::Beep(700, 200);
+       }
+}
+
+VOID CLeashView::OnUpdateProperties(CCmdUI* pCmdUI)
+{
+    if (CLeashApp::m_hKrb5DLL || CLeashApp::m_hKrb4DLL)
+        pCmdUI->Enable();
+    else
+        pCmdUI->Enable(FALSE);
+}
+
+VOID CLeashView::OnUpdateKrb4Properties(CCmdUI* pCmdUI)
+{
+    if (CLeashApp::m_hKrb4DLL)
+        pCmdUI->Enable();
+    else
+        pCmdUI->Enable(FALSE);
+}
+
+VOID CLeashView::OnUpdateKrb5Properties(CCmdUI* pCmdUI)
+{
+    if (CLeashApp::m_hKrb5DLL)
+        pCmdUI->Enable();
+    else
+        pCmdUI->Enable(FALSE);
+}
+
+VOID CLeashView::OnUpdateAfsControlPanel(CCmdUI* pCmdUI)
+{
+    // need Krb 4 to get AFS tokens
+    if (CLeashApp::m_hAfsDLL && CLeashApp::m_hKrb4DLL)
+        pCmdUI->Enable();
+    else
+        pCmdUI->m_pMenu->DeleteMenu(pCmdUI->m_nID, MF_BYCOMMAND);
+}
+
+void CLeashView::OnHelpLeash32()
+{
+#ifdef CALL_HTMLHELP
+       AfxGetApp()->HtmlHelp(HID_LEASH_PROGRAM);
+#else
+    AfxGetApp()->WinHelp(HID_LEASH_PROGRAM);
+#endif
+}
+
+void CLeashView::OnHelpKerberos()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_ABOUT_KERBEROS);
+#else
+    AfxGetApp()->WinHelp(HID_ABOUT_KERBEROS);
+#endif
+}
+
+void CLeashView::OnHelpWhyuseleash32()
+{
+#ifdef CALL_HTMLHELP
+    AfxGetApp()->HtmlHelp(HID_WHY_USE_LEASH32);
+#else
+    AfxGetApp()->WinHelp(HID_WHY_USE_LEASH32);
+#endif
+}
+
+void CLeashView::OnSysColorChange()
+{
+    change_icon_size = FALSE;
+    CWnd::OnSysColorChange();
+    OnLargeIcons();
+    m_imageList.SetBkColor(GetSysColor(COLOR_WINDOW));
+    change_icon_size = TRUE;
+}
+
+
+LRESULT
+CLeashView::OnObtainTGTWithParam(WPARAM wParam, LPARAM lParam)
+{
+    LRESULT res = 0;
+    char * param = (char *) GlobalLock((HGLOBAL) lParam);
+    LSH_DLGINFO_EX ldi;
+    ldi.size = sizeof(ldi);
+    ldi.dlgtype = DLGTYPE_PASSWD;
+    ldi.use_defaults = 1;
+    ldi.title = ldi.in.title;
+    ldi.username = ldi.in.username;
+    ldi.realm = ldi.in.realm;
+    if ( param ) {
+        if ( *param )
+            strcpy(ldi.in.title,param);
+        param += strlen(param) + 1;
+        if ( *param )
+            strcpy(ldi.in.username,param);
+        param += strlen(param) + 1;
+        if ( *param )
+            strcpy(ldi.in.realm,param);
+        param += strlen(param) + 1;
+       if ( *param )
+           strcpy(ldi.in.ccache,param);
+    } else {
+        strcpy(ldi.in.title,"Initialize Ticket");
+    }
+
+    res = pLeash_kinit_dlg_ex(m_hWnd, &ldi);
+    GlobalUnlock((HGLOBAL) lParam);
+    ::SendMessage(m_hWnd, WM_COMMAND, ID_UPDATE_DISPLAY, 0);
+    return res;
+}
diff --git a/src/windows/leash/LeashView.h b/src/windows/leash/LeashView.h
new file mode 100644 (file)
index 0000000..591bc42
--- /dev/null
@@ -0,0 +1,253 @@
+//     **************************************************************************************
+//     File:                   LeashView.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for LeashView.cpp. Contains variables and functions
+//                                     for the Leash FormView
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
+#define AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#define GOOD_TICKETS   1  // Don't change this value
+#define EXPIRED_TICKETS 2  // Don't change this value
+#define TICKETS_LOW            3
+#define ONE_SECOND             1000
+#define SMALL_ICONS     16
+#define LARGE_ICONS     32
+
+#define UPDATE_DISPLAY_TIME 60  //seconds
+
+#define ACTIVE_CLOCK          0
+#define LOW_CLOCK             1
+#define EXPIRED_CLOCK         2
+#define ACTIVE_TICKET         3
+#define LOW_TICKET            4
+#define EXPIRED_TICKET        5
+#define TICKET_NOT_INSTALLED  6
+#define ACTIVE_PARENT_NODE    7
+#define LOW_PARENT_NODE       8
+#define EXPIRED_PARENT_NODE   9
+#define NONE_PARENT_NODE      10
+#define LOW_TRAY_ICON         11
+#define EXPIRED_TRAY_ICON     12
+#define ACTIVE_TRAY_ICON      13
+#define NONE_TRAY_ICON        14
+#define TKT_ADDRESS           15
+#define TKT_SESSION           16
+#define TKT_ENCRYPTION        17
+#define IMAGE_COUNT           18
+
+#define NODE_IS_EXPANDED 2
+
+#define CX_BORDER   1
+#define CY_BORDER   1
+
+#ifdef NO_TICKETS
+#undef NO_TICKETS // XXX - this is evil but necessary thanks to silliness...
+#endif
+
+#define WM_TRAYICON (WM_USER+100)
+
+enum ticketTimeLeft{NO_TICKETS, ZERO_MINUTES_LEFT, FIVE_MINUTES_LEFT, TEN_MINUTES_LEFT,
+                                       FIFTEEN_MINUTES_LEFT, TWENTY_MINUTES_LEFT, PLENTY_OF_TIME,
+                    NOT_INSTALLED};
+// Don't change 'NO_TICKET's' value
+
+class CLeashDebugWindow;
+
+class CLeashView : public CFormView
+{
+private:
+    TicketList*         m_listKrb4;
+    TicketList*         m_listKrb5;
+    TicketList*         m_listAfs;
+    CLeashDebugWindow* m_pDebugWindow;
+       CImageList                      m_imageList;
+       CImageList                      *m_pImageList;
+    CTreeCtrl*                 m_pTree;
+       CWinApp*                        m_pApp;
+       HTREEITEM                       m_hPrincipal;
+       HTREEITEM                       m_hKerb4;
+       HTREEITEM                       m_hKerb5;
+    HTREEITEM           m_hk5tkt;
+       HTREEITEM                       m_hAFS;
+       TV_INSERTSTRUCT         m_tvinsert;
+       HMENU                           m_hMenu;
+    BOOL                               m_startup;
+       BOOL                            m_isMinimum;
+       BOOL                            m_debugStartUp;
+       BOOL                            m_alreadyPlayed;
+    INT                                        m_upperCaseRealm;
+       INT                                     m_destroyTicketsOnExit;
+       INT                                     m_debugWindow;
+       INT                                     m_largeIcons;
+       INT                                     m_lowTicketAlarm;
+       INT                                     m_hPrincipalState;
+       INT                                     m_hKerb4State;
+       INT                                     m_hKerb5State;
+       INT                                     m_hAFSState;
+    BOOL                m_bIconAdded;
+    BOOL                m_bIconDeleted;
+
+    static INT                 m_autoRenewTickets;
+    static INT          m_ticketStatusAfs;
+    static INT          m_ticketStatusKrb4;
+    static INT          m_ticketStatusKrb5;
+    static INT          m_autoRenewalAttempted;
+       static INT                      m_warningOfTicketTimeLeftAfs;
+       static INT                      m_warningOfTicketTimeLeftKrb4;
+       static INT                      m_warningOfTicketTimeLeftKrb5;
+    static INT                 m_warningOfTicketTimeLeftLockAfs;
+    static INT                 m_warningOfTicketTimeLeftLockKrb4;
+    static INT                 m_warningOfTicketTimeLeftLockKrb5;
+    static INT                 m_updateDisplayCount;
+    static INT         m_alreadyPlayedDisplayCount;
+    static LONG                        m_ticketTimeLeft;
+       static BOOL                     m_lowTicketAlarmSound;
+    static LONG         m_timerMsgNotInProgress;
+
+       VOID ResetTreeNodes();
+    VOID ApplicationInfoMissingMsg();
+    VOID GetScrollBarState(CSize sizeClient, CSize& needSb,
+                              CSize& sizeRange, CPoint& ptMove,
+                           BOOL bInsideClient);
+    VOID UpdateBars();
+    VOID GetScrollBarSizes(CSize& sizeSb);
+    BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
+
+    //void   GetRowWidthHeight(CDC* pDC, LPCSTR theString, int& nRowWidth,
+    //                         int& nRowHeight, int& nCharWidth);
+    static VOID        AlarmBeep();
+       static VOID     CALLBACK EXPORT TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent,
+                                          DWORD dwTime);
+       static VOID     UpdateTicketTime(TICKETINFO& ticketinfo);
+       static INT      GetLowTicketStatus(int);
+       static LONG     LeashTime();
+
+    void   SetTrayIcon(int nim, int state=0);
+    void   SetTrayText(int nim, CString tip);
+
+    BOOL   UpdateDisplay();
+    static UINT InitTicket(void *);
+       static UINT RenewTicket(void *);
+       static UINT ImportTicket(void *);
+
+protected: // create from serialization only
+       DECLARE_DYNCREATE(CLeashView)
+
+// Attributes
+public:
+       static INT   m_forwardableTicket;
+       static INT   m_proxiableTicket;
+    static INT   m_renewableTicket;
+    static INT   m_noaddressTicket;
+    static DWORD m_publicIPAddress;
+    static BOOL  m_importedTickets;
+
+    CLeashView();
+       //LeashDoc* GetDocument();
+
+       //{{AFX_DATA(CLeashView)
+       enum { IDD = IDD_DIALOG1 };
+               // NOTE: the ClassWizard will add data members here
+       //}}AFX_DATA
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CLeashView)
+       public:
+       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+       virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
+       virtual VOID OnInitialUpdate();
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual VOID OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CLeashView();
+
+#ifdef _DEBUG
+       virtual VOID AssertValid() const;
+       virtual VOID Dump(CDumpContext& dc) const;
+#endif
+
+// Generated message map functions
+protected:
+       //{{AFX_MSG(CLeashView)
+    afx_msg VOID OnItemexpandedTreeview(NMHDR* pNMHDR, LRESULT* pResult);
+       afx_msg INT OnCreate(LPCREATESTRUCT lpCreateStruct);
+       afx_msg VOID OnShowWindow(BOOL bShow, UINT nStatus);
+    afx_msg VOID OnClose(void);
+       afx_msg VOID OnInitTicket();
+       afx_msg VOID OnRenewTicket();
+       afx_msg VOID OnImportTicket();
+       afx_msg VOID OnDestroyTicket();
+       afx_msg VOID OnChangePassword();
+       afx_msg VOID OnUpdateDisplay();
+       afx_msg VOID OnSynTime();
+       afx_msg VOID OnDebugMode();
+       afx_msg VOID OnLargeIcons();
+       afx_msg VOID OnUppercaseRealm();
+       afx_msg VOID OnKillTixOnExit();
+       afx_msg VOID OnDestroy();
+       afx_msg VOID OnUpdateDestroyTicket(CCmdUI* pCmdUI);
+       afx_msg VOID OnUpdateImportTicket(CCmdUI* pCmdUI);
+       afx_msg VOID OnUpdateInitTicket(CCmdUI* pCmdUI);
+       afx_msg VOID OnUpdateRenewTicket(CCmdUI* pCmdUI);
+       afx_msg VOID OnAppAbout();
+       afx_msg VOID OnAfsControlPanel();
+       afx_msg VOID OnUpdateDebugMode(CCmdUI* pCmdUI);
+       afx_msg VOID OnUpdateCfgFiles(CCmdUI* pCmdUI);
+       afx_msg VOID OnKrb4Properties();
+       afx_msg VOID OnKrb5Properties();
+       afx_msg void OnLeashProperties();
+       afx_msg void OnLeashRestore();
+       afx_msg void OnLeashMinimize();
+       afx_msg void OnLowTicketAlarm();
+       afx_msg void OnUpdateKrb4Properties(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateKrb5Properties(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateAfsControlPanel(CCmdUI* pCmdUI);
+    afx_msg void OnKrbProperties();
+       afx_msg void OnUpdateProperties(CCmdUI* pCmdUI);
+       afx_msg void OnHelpKerberos();
+       afx_msg void OnHelpLeash32();
+       afx_msg void OnHelpWhyuseleash32();
+    afx_msg void OnSysColorChange();
+    afx_msg void OnAutoRenew();
+       afx_msg LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam);
+       afx_msg LRESULT OnTrayIcon(WPARAM wParam, LPARAM lParam);
+    afx_msg LRESULT OnObtainTGTWithParam(WPARAM wParam, LPARAM lParam);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/*
+#ifndef _DEBUG  // debug version in CLeashView.cpp
+inline LeashDoc* CLeashView::GetDocument()
+   { return (LeashDoc*)m_pDocument; }
+#endif
+*/
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/Lglobals.cpp b/src/windows/leash/Lglobals.cpp
new file mode 100644 (file)
index 0000000..861255e
--- /dev/null
@@ -0,0 +1,148 @@
+//*****************************************************************************
+// File:       lgobals.cpp
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  @1998 Massachusetts Institute of Technology - All rights
+//              reserved.
+// Description:        CPP file for lgobals.cpp. Contains global variables and helper
+//             functions
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 02/02/98    ADL     Original
+//*****************************************************************************
+
+#include "stdafx.h"
+#include "leash.h"
+#include <direct.h>
+#include "lglobals.h"
+
+static const char *const conf_yes[] = {
+    "y", "yes", "true", "t", "1", "on",
+    0,
+};
+
+static const char *const conf_no[] = {
+    "n", "no", "false", "nil", "0", "off",
+    0,
+};
+
+int
+config_boolean_to_int(const char *s)
+{
+    const char *const *p;
+
+    for(p=conf_yes; *p; p++) {
+        if (!strcasecmp(*p,s))
+            return 1;
+    }
+
+    for(p=conf_no; *p; p++) {
+        if (!strcasecmp(*p,s))
+            return 0;
+    }
+
+    /* Default to "no" */
+    return 0;
+}
+
+
+// Global Function for deleting or putting a value in the Registry
+BOOL SetRegistryVariable(const CString& regVariable,
+                         const CString& regValue,
+                         const char* regSubKey)
+{
+    // Set Register Variable
+    HKEY hKey = NULL;
+    LONG err = 0L;
+
+
+    if (ERROR_SUCCESS != (err = RegOpenKeyEx(HKEY_CURRENT_USER,
+                                             regSubKey,
+                                             0, KEY_ALL_ACCESS, &hKey)))
+    {
+        if ((err = RegCreateKeyEx(HKEY_CURRENT_USER, regSubKey, 0, 0, 0,
+                                  KEY_ALL_ACCESS, 0, &hKey, 0)))
+        {
+            // Error
+            return TRUE;
+        }
+    }
+
+    if (ERROR_SUCCESS == err && hKey)
+    {
+        if (regValue.IsEmpty())
+        {
+            // Delete
+            RegDeleteValue(hKey, regVariable);
+        }
+        else
+        {
+            // Insure that Name (Variable) is in the Registry and set
+            // it's new value
+            char nVariable[MAX_PATH+1];
+            char* pVARIABLE = nVariable;
+            strncpy(pVARIABLE, regValue, MAX_PATH);
+
+            if (ERROR_SUCCESS !=
+                RegSetValueEx(hKey, regVariable, 0,
+                              REG_SZ, (const unsigned char*)pVARIABLE,
+                              lstrlen(regValue)))
+            {
+                // Error
+                return FALSE;
+            }
+        }
+
+        RegCloseKey(hKey);
+
+        // Send this message to all top-level windows in the system
+        ::PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0L, (LPARAM) regSubKey);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+VOID LeashErrorBox(LPCSTR errorMsg, LPCSTR insertedString, LPCSTR errorFlag)
+{
+    CString strMessage;
+    strMessage = errorMsg;
+    strMessage += ": ";
+    strMessage += insertedString;
+
+    MessageBox(CLeashApp::m_hProgram, strMessage, errorFlag, MB_OK);
+
+    //if (*errorFlag == 'E')
+    //ASSERT(0); // on error condition only
+}
+
+Directory::Directory(LPCSTR pathToValidate)
+{
+    m_pathToValidate = pathToValidate;
+    _getdcwd(_getdrive(), m_savCurPath, sizeof(m_savCurPath));
+}
+
+Directory::~Directory()
+{
+    if (-1 == _chdir(m_savCurPath))
+        ASSERT(0);
+}
+
+BOOL Directory::IsValidDirectory()
+{
+    if (-1 == _chdir(m_pathToValidate))
+        return FALSE;
+
+    return TRUE;
+}
+
+BOOL Directory::IsValidFile()
+{
+    CFileFind fileFind;
+    if (!fileFind.FindFile(m_pathToValidate))
+        return FALSE;
+
+    return TRUE;
+}
diff --git a/src/windows/leash/Lglobals.h b/src/windows/leash/Lglobals.h
new file mode 100644 (file)
index 0000000..7407b3b
--- /dev/null
@@ -0,0 +1,272 @@
+//*****************************************************************************
+// File:       lgobals.h
+// By:         Arthur David Leather
+// Created:    12/02/98
+// Copyright:  @1998 Massachusetts Institute of Technology - All rights
+//              reserved.
+// Description:        H file for lgobals.cpp. Contains global variables and helper
+//             functions
+//
+// History:
+//
+// MM/DD/YY    Inits   Description of Change
+// 02/02/98    ADL     Original
+//*****************************************************************************
+
+#if !defined LEASHGLOBALS_H
+#define LEASHGLOBALS_H
+
+#include <tlhelp32.h>
+#include <loadfuncs-krb5.h>
+#include <loadfuncs-krb.h>
+#include <loadfuncs-profile.h>
+#include <loadfuncs-leash.h>
+
+typedef struct TicketList
+{
+    char* theTicket;
+    TicketList* next;
+    char* tktEncType;
+    char* keyEncType;
+    int   addrCount;
+    char ** addrList;
+    char * name;
+    char * inst;
+    char * realm;
+} TicketList;
+
+// toolhelp functions
+TYPEDEF_FUNC(
+    HANDLE,
+    WINAPI,
+    CreateToolhelp32Snapshot,
+    (DWORD, DWORD)
+    );
+TYPEDEF_FUNC(
+    BOOL,
+    WINAPI,
+    Module32First,
+    (HANDLE, LPMODULEENTRY32)
+    );
+TYPEDEF_FUNC(
+    BOOL,
+    WINAPI,
+    Module32Next,
+    (HANDLE, LPMODULEENTRY32)
+    );
+
+// psapi functions
+TYPEDEF_FUNC(
+    DWORD,
+    WINAPI,
+    GetModuleFileNameExA,
+    (HANDLE, HMODULE, LPSTR, DWORD)
+    );
+TYPEDEF_FUNC(
+    BOOL,
+    WINAPI,
+    EnumProcessModules,
+    (HANDLE, HMODULE*, DWORD, LPDWORD)
+    );
+
+#define pGetModuleFileNameEx pGetModuleFileNameExA
+
+// leash functions
+TYPEDEF_FUNC(
+    long,
+    WINAPIV,
+    not_an_API_LeashKRB4GetTickets,
+    (TICKETINFO *, TicketList **)
+    );
+TYPEDEF_FUNC(
+    long,
+    WINAPIV,
+    not_an_API_LeashKRB5GetTickets,
+    (TICKETINFO *, TicketList **, krb5_context *)
+    );
+TYPEDEF_FUNC(
+    long,
+    WINAPIV,
+    not_an_API_LeashAFSGetToken,
+    (TICKETINFO *, TicketList **, char *)
+    );
+TYPEDEF_FUNC(
+    long,
+    WINAPIV,
+    not_an_API_LeashFreeTicketList,
+    (TicketList**)
+    );
+TYPEDEF_FUNC(
+    long,
+    WINAPIV,
+    not_an_API_LeashGetTimeServerName,
+    (char *, const char*)
+    );
+
+extern DECL_FUNC_PTR(not_an_API_LeashKRB4GetTickets);
+extern DECL_FUNC_PTR(not_an_API_LeashKRB5GetTickets);
+extern DECL_FUNC_PTR(not_an_API_LeashAFSGetToken);
+extern DECL_FUNC_PTR(not_an_API_LeashFreeTicketList);
+extern DECL_FUNC_PTR(not_an_API_LeashGetTimeServerName);
+extern DECL_FUNC_PTR(Leash_kdestroy);
+extern DECL_FUNC_PTR(Leash_changepwd_dlg);
+extern DECL_FUNC_PTR(Leash_changepwd_dlg_ex);
+extern DECL_FUNC_PTR(Leash_kinit_dlg);
+extern DECL_FUNC_PTR(Leash_kinit_dlg_ex);
+extern DECL_FUNC_PTR(Leash_timesync);
+extern DECL_FUNC_PTR(Leash_get_default_lifetime);
+extern DECL_FUNC_PTR(Leash_set_default_lifetime);
+extern DECL_FUNC_PTR(Leash_get_default_forwardable);
+extern DECL_FUNC_PTR(Leash_set_default_forwardable);
+extern DECL_FUNC_PTR(Leash_get_default_renew_till);
+extern DECL_FUNC_PTR(Leash_set_default_renew_till);
+extern DECL_FUNC_PTR(Leash_get_default_noaddresses);
+extern DECL_FUNC_PTR(Leash_set_default_noaddresses);
+extern DECL_FUNC_PTR(Leash_get_default_proxiable);
+extern DECL_FUNC_PTR(Leash_set_default_proxiable);
+extern DECL_FUNC_PTR(Leash_get_default_publicip);
+extern DECL_FUNC_PTR(Leash_set_default_publicip);
+extern DECL_FUNC_PTR(Leash_get_default_use_krb4);
+extern DECL_FUNC_PTR(Leash_set_default_use_krb4);
+extern DECL_FUNC_PTR(Leash_get_default_life_min);
+extern DECL_FUNC_PTR(Leash_set_default_life_min);
+extern DECL_FUNC_PTR(Leash_get_default_life_max);
+extern DECL_FUNC_PTR(Leash_set_default_life_max);
+extern DECL_FUNC_PTR(Leash_get_default_renew_min);
+extern DECL_FUNC_PTR(Leash_set_default_renew_min);
+extern DECL_FUNC_PTR(Leash_get_default_renew_max);
+extern DECL_FUNC_PTR(Leash_set_default_renew_max);
+extern DECL_FUNC_PTR(Leash_get_default_renewable);
+extern DECL_FUNC_PTR(Leash_set_default_renewable);
+extern DECL_FUNC_PTR(Leash_get_lock_file_locations);
+extern DECL_FUNC_PTR(Leash_set_lock_file_locations);
+extern DECL_FUNC_PTR(Leash_get_default_uppercaserealm);
+extern DECL_FUNC_PTR(Leash_set_default_uppercaserealm);
+extern DECL_FUNC_PTR(Leash_get_default_mslsa_import);
+extern DECL_FUNC_PTR(Leash_set_default_mslsa_import);
+extern DECL_FUNC_PTR(Leash_get_default_preserve_kinit_settings);
+extern DECL_FUNC_PTR(Leash_set_default_preserve_kinit_settings);
+extern DECL_FUNC_PTR(Leash_import);
+extern DECL_FUNC_PTR(Leash_importable);
+extern DECL_FUNC_PTR(Leash_renew);
+extern DECL_FUNC_PTR(Leash_reset_defaults);
+
+#define pLeashKRB4GetTickets     pnot_an_API_LeashKRB4GetTickets
+#define pLeashKRB5GetTickets     pnot_an_API_LeashKRB5GetTickets
+#define pLeashAFSGetToken        pnot_an_API_LeashAFSGetToken
+#define pLeashFreeTicketList     pnot_an_API_LeashFreeTicketList
+#define pLeashGetTimeServerName  pnot_an_API_LeashGetTimeServerName
+
+// krb4 functions
+extern DECL_FUNC_PTR(set_krb_debug);
+extern DECL_FUNC_PTR(set_krb_ap_req_debug);
+extern DECL_FUNC_PTR(krb_get_krbconf2);
+extern DECL_FUNC_PTR(krb_get_krbrealm2);
+extern DECL_FUNC_PTR(tkt_string);
+extern DECL_FUNC_PTR(krb_set_tkt_string);
+extern DECL_FUNC_PTR(krb_realmofhost);
+extern DECL_FUNC_PTR(krb_get_lrealm);
+extern DECL_FUNC_PTR(krb_get_krbhst);
+
+// psapi functions
+extern DECL_FUNC_PTR(GetModuleFileNameExA);
+extern DECL_FUNC_PTR(EnumProcessModules);
+
+// toolhelp functions
+extern DECL_FUNC_PTR(CreateToolhelp32Snapshot);
+extern DECL_FUNC_PTR(Module32First);
+extern DECL_FUNC_PTR(Module32Next);
+
+// krb5 functions
+extern DECL_FUNC_PTR(krb5_cc_default_name);
+extern DECL_FUNC_PTR(krb5_cc_set_default_name);
+extern DECL_FUNC_PTR(krb5_get_default_config_files);
+extern DECL_FUNC_PTR(krb5_free_config_files);
+extern DECL_FUNC_PTR(krb5_free_context);
+extern DECL_FUNC_PTR(krb5_get_default_realm);
+extern DECL_FUNC_PTR(krb5_free_default_realm);
+extern DECL_FUNC_PTR(krb5_cc_get_principal);
+extern DECL_FUNC_PTR(krb5_build_principal);
+extern DECL_FUNC_PTR(krb5_c_random_make_octets);
+extern DECL_FUNC_PTR(krb5_get_init_creds_password);
+extern DECL_FUNC_PTR(krb5_free_cred_contents);
+extern DECL_FUNC_PTR(krb5_cc_resolve);
+extern DECL_FUNC_PTR(krb5_unparse_name);
+extern DECL_FUNC_PTR(krb5_free_unparsed_name);
+extern DECL_FUNC_PTR(krb5_free_principal);
+extern DECL_FUNC_PTR(krb5_cc_close);
+// extern DECL_FUNC_PTR(krb5_get_host_realm);
+
+// profile functions
+extern DECL_FUNC_PTR(profile_release);
+extern DECL_FUNC_PTR(profile_init);
+extern DECL_FUNC_PTR(profile_flush);
+extern DECL_FUNC_PTR(profile_rename_section);
+extern DECL_FUNC_PTR(profile_update_relation);
+extern DECL_FUNC_PTR(profile_clear_relation);
+extern DECL_FUNC_PTR(profile_add_relation);
+extern DECL_FUNC_PTR(profile_get_relation_names);
+extern DECL_FUNC_PTR(profile_get_subsection_names);
+extern DECL_FUNC_PTR(profile_get_values);
+extern DECL_FUNC_PTR(profile_free_list);
+extern DECL_FUNC_PTR(profile_abandon);
+extern DECL_FUNC_PTR(profile_get_string);
+extern DECL_FUNC_PTR(profile_release_string);
+
+#define SKIP_MINSIZE  0
+#define LEFT_SIDE     1
+#define RIGHT_SIDE    2
+#define TOP_SIDE      3
+#define RESET_MINSIZE 4
+#define BOTTOM_SIDE   6
+
+#define ADMIN_SERVER "admin_server"
+
+#define ON  1
+#define OFF 0
+#define TRUE_FLAG              1
+#define FALSE_FLAG             0
+#define LEASHDLL "leashw32.dll"
+#define KERB4DLL "krbv4w32.dll"
+#define KERB5DLL "krb5_32.dll"
+#define KERB5_PPROFILE_DLL "xpprof32.dll"
+#define SECUR32DLL "secur32.dll"
+
+#define KRB_FILE               "KRB.CON"
+#define KRBREALM_FILE  "KRBREALM.CON"
+#define TICKET_FILE            "TICKET.KRB"
+#define WIN95_AUTOEXEC  "C:\\AUTOEXEC.BAT"
+
+#define LEASH_HELP_FILE "leash32.chm"
+
+extern int  config_boolean_to_int(const char *);
+extern BOOL SetRegistryVariable(const CString& regVariable,
+                                const CString& regValue,
+                                const char* regSubKey = "Software\\MIT\\Leash32\\Settings");
+extern VOID LeashErrorBox(LPCSTR errorMsg, LPCSTR insertedString,
+                          LPCSTR errorFlag = "Error");
+
+
+class Directory
+{
+    CHAR m_savCurPath[MAX_PATH];
+    CString m_pathToValidate;
+
+public:
+    Directory(LPCSTR pathToValidate);
+    virtual ~Directory();
+
+    BOOL IsValidDirectory();
+    BOOL IsValidFile();
+};
+
+class TicketInfoWrapper {
+  public:
+    HANDLE     lockObj;
+    TICKETINFO Krb4;
+    TICKETINFO Krb5;
+    TICKETINFO Afs;
+};
+extern TicketInfoWrapper ticketinfo;
+
+#endif
diff --git a/src/windows/leash/MainFrm.cpp b/src/windows/leash/MainFrm.cpp
new file mode 100644 (file)
index 0000000..b2d20cc
--- /dev/null
@@ -0,0 +1,465 @@
+//     **************************************************************************************
+//     File:                   MainFrm.cpp
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    CPP file for MainFrm.h. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#include "stdafx.h"
+#include "Leash.h"
+#include "MainFrm.h"
+#include "lglobals.h"
+//#include "KrbRealmHostMaintenance.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CMainFrame
+
+#define MIN_LEFT      179
+#define MIN_TOP                  61
+#define MIN_RIGHT        530
+#define MIN_BOTTOM       280
+
+CStatusBar CMainFrame::m_wndStatusBar;
+CToolBar   CMainFrame::m_wndToolBar;
+CImageList CMainFrame::m_imageList;
+CImageList CMainFrame::m_disabledImageList;
+BOOL      CMainFrame::m_isMinimum;
+BOOL       CMainFrame::m_isBeingResized;
+int        CMainFrame::m_whatSide;
+
+IMPLEMENT_DYNCREATE(CMainFrame, CLeashFrame)
+
+BEGIN_MESSAGE_MAP(CMainFrame, CLeashFrame)
+       //{{AFX_MSG_MAP(CMainFrame)
+       ON_WM_CREATE()
+       ON_COMMAND(ID_RESET_WINDOW_SIZE, OnResetWindowSize)
+       ON_WM_SIZING()
+    ON_WM_CLOSE()
+       ON_WM_GETMINMAXINFO()
+    ON_COMMAND(ID_APP_EXIT, OnClose)
+       //}}AFX_MSG_MAP
+       // Global help commands
+       ON_COMMAND(ID_HELP_LEASH_, CMainFrame::OnHelpFinder)
+       ON_COMMAND(ID_HELP, CMainFrame::OnHelp)
+       ON_COMMAND(ID_CONTEXT_HELP, CMainFrame::OnContextHelp)
+END_MESSAGE_MAP()
+
+static UINT indicators[] =
+{
+       ID_SEPARATOR,           // status line indicator
+       ID_SEPARATOR,
+    ID_SEPARATOR,
+    ID_SEPARATOR
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMainFrame construction/destruction
+
+CMainFrame::CMainFrame()
+{
+       m_winRectLeft = 0;
+       m_winRectTop = 0;
+       m_winRectRight = 0;
+       m_winRectBottom = 0;
+       m_whatSide = RESET_MINSIZE;
+       m_isMinimum = FALSE;
+    m_isBeingResized = FALSE;
+    m_bOwnerCreated = FALSE;
+}
+
+CMainFrame::~CMainFrame()
+{
+}
+
+int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+       if (CLeashFrame::OnCreate(lpCreateStruct) == -1)
+               return -1;
+
+    ShowWindow(SW_HIDE);
+
+/* NT4 and NT5 aren't shipped with a version of MFC that supports
+// 'CreateEx()' as of 2/1/99
+#if _MFC_VER > 0x0421
+
+       if (!m_wndToolBar.CreateEx(this) ||
+               !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+       {
+               TRACE0("Failed to create toolbar\n");
+               return -1;      // fail to create
+       }
+
+#else
+
+       if (!m_wndToolBar.Create(this) ||
+               !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+       {
+               TRACE0("Failed to create toolbar\n");
+               return -1;      // fail to create
+       }
+
+#endif
+*/
+
+       if (!m_wndToolBar.Create(this) ||
+               !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+       {
+               MessageBox("There is problem creating the Leash Toolbar!",
+                   "Error", MB_OK);
+        TRACE0("Failed to create toolbar\n");
+               return -1;      // fail to create
+       }
+
+    // Create an image list of Icons so that we can use the best color
+    // depth available on the system and then assign this new list to
+    // be used instead of the single bitmap file assigned to the toolbar
+    // in the resource file
+    CToolBarCtrl *_toolBar = NULL;
+    CToolBarCtrl& toolBar = CMainFrame::m_wndToolBar.GetToolBarCtrl();
+    HICON      hIcon[7];
+    int n;
+
+    for (n = 0; n < 7; n++)
+    {
+        hIcon[n] = NULL;
+    }
+
+    UINT bitsPerPixel = GetDeviceCaps( ::GetDC(::GetDesktopWindow()), BITSPIXEL);
+    UINT ilcColor;
+    if ( bitsPerPixel >= 32 )
+        ilcColor = ILC_COLOR32;
+    else if ( bitsPerPixel >= 24 )
+        ilcColor = ILC_COLOR24;
+    else if ( bitsPerPixel >= 16 )
+        ilcColor = ILC_COLOR16;
+    else if ( bitsPerPixel >= 8 )
+        ilcColor = ILC_COLOR8;
+    else
+        ilcColor = ILC_COLOR;
+
+    m_imageList.Create(18, 18, ilcColor | ILC_MASK, 8, 4);
+    m_imageList.SetBkColor(GetSysColor(COLOR_BTNFACE));
+
+    hIcon[0] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_INIT);
+    hIcon[1] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_RENEW);
+    hIcon[2] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_IMPORT);
+    hIcon[3] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_DESTROY);
+    hIcon[4] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_PASSWORD);
+    hIcon[5] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_REFRESH);
+    hIcon[6] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_SYNC);
+
+    for (n = 0; n < 7; n++)
+    {
+        m_imageList.Add(hIcon[n]);
+    }
+    toolBar.SetImageList(&m_imageList);
+
+    m_disabledImageList.Create(18, 18, ilcColor | ILC_MASK, 8, 4);
+    m_disabledImageList.SetBkColor(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
+
+    hIcon[0] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_INIT_DISABLED);
+    hIcon[1] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_RENEW_DISABLED);
+    hIcon[2] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_IMPORT_DISABLED);
+    hIcon[3] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_DESTROY_DISABLED);
+    hIcon[4] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_PASSWORD_DISABLED);
+    hIcon[5] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_REFRESH_DISABLED);
+    hIcon[6] = AfxGetApp()->LoadIcon(IDI_TOOLBAR_SYNC_DISABLED);
+
+    for (n = 0; n < 7; n++)
+    {
+        m_disabledImageList.Add(hIcon[n]);
+    }
+    toolBar.SetDisabledImageList(&m_disabledImageList);
+
+       if (!m_wndStatusBar.Create(this) ||
+               !m_wndStatusBar.SetIndicators(indicators,
+                 (CLeashApp::m_hAfsDLL ? 4 : 3)))
+       {
+               MessageBox("There is problem creating the Leash Status Bar!",
+                   "Error", MB_OK);
+        TRACE0("Failed to create status bar\n");
+               return -1;      // fail to create
+       }
+
+       // TODO: Remove this if you don't want tool tips or a resizeable toolbar
+       m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
+                                    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+
+       // TODO: Delete these three lines if you don't want the toolbar to
+       //  be dockable
+       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
+       EnableDocking(CBRS_ALIGN_ANY);
+       //DockControlBar(&m_wndToolBar);
+
+       return 0;
+}
+
+BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
+{
+    if ( pMsg->message == WM_SYSCOMMAND && (pMsg->wParam & 0xfff0) == SC_CLOSE )
+    {
+        return TRUE;
+    }
+    return CLeashFrame::PreTranslateMessage(pMsg);
+}
+
+BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
+{
+       // Use the specific class name we established earlier
+    // Remove the Minimize and Maximize buttons
+    cs.style &= ~WS_MINIMIZEBOX;
+    cs.style &= ~WS_MAXIMIZEBOX;
+    // Initialize the extended window style to display a TaskBar entry with WS_EX_APPWINDOW
+    cs.dwExStyle |= WS_EX_APPWINDOW;
+    cs.dwExStyle |= WS_EX_OVERLAPPEDWINDOW ;
+       cs.lpszClass = _T("LEASH.0WNDCLASS");
+    cs.lpszName = _T("Leash32");
+
+    CString strText = AfxGetApp()->GetProfileString(CLeashFrame::s_profileHeading,
+                                                    CLeashFrame::s_profileRect);
+    if (!strText.IsEmpty())
+    {
+        CRect rect;
+
+        rect.left = atoi((const char*) strText);
+        rect.top = atoi((const char*) strText + 5);
+        rect.right = atoi((const char*) strText + 10);
+        rect.bottom = atoi((const char*) strText + 15);
+
+        cs.x = rect.left;
+        cs.y = rect.top;
+        cs.cx = rect.right - rect.left;
+        cs.cy = rect.bottom - rect.top;
+
+        if ( cs.x < 0 )
+            cs.x = CW_USEDEFAULT;
+        if ( cs.y < 0 )
+            cs.y = CW_USEDEFAULT;
+        if ( cs.cx <= 0 )
+            cs.cx = CLeashFrame::s_rectDefault.right;
+        if ( cs.cy <= 0 )
+            cs.cy = CLeashFrame::s_rectDefault.bottom;
+    }
+    else
+    {
+        cs.cx = CLeashFrame::s_rectDefault.right;
+        cs.cy = CLeashFrame::s_rectDefault.bottom;
+        cs.y = CW_USEDEFAULT;
+        cs.x = CW_USEDEFAULT;
+    }
+
+    // Change the following line to call
+       // CLeashFrame::PreCreateWindow(cs) if this is an SDI application.
+       if (!CLeashFrame::PreCreateWindow(cs))
+        return FALSE;
+
+    // We create a parent window for our application to ensure that
+    // it has an owner.  This way we can disable the TaskBar entry
+    // by removing the WS_EX_APPWINDOW style later on.
+    if ( !m_bOwnerCreated )
+    {
+        m_bOwnerCreated = m_MainFrameOwner.Create(IDD_FRAMEOWNER);
+        if ( m_bOwnerCreated )
+            m_MainFrameOwner.ShowWindow(SW_HIDE);
+    }
+    if ( m_bOwnerCreated )
+        cs.hwndParent = m_MainFrameOwner.GetSafeHwnd();
+
+    return TRUE;
+}
+
+
+BOOL CMainFrame::ShowTaskBarButton(BOOL bVisible)
+{
+    if (!m_bOwnerCreated)
+        return FALSE;
+
+    if (bVisible) {
+        ShowWindow(SW_HIDE);
+        ModifyStyleEx(0, WS_EX_APPWINDOW);
+        ShowWindow(SW_SHOW);
+    } else {
+        ShowWindow(SW_HIDE);
+        ModifyStyleEx(WS_EX_APPWINDOW, 0);
+        ShowWindow(SW_SHOW);
+    }
+    return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CMainFrame diagnostics
+
+#ifdef _DEBUG
+void CMainFrame::AssertValid() const
+{
+       CLeashFrame::AssertValid();
+}
+
+void CMainFrame::Dump(CDumpContext& dc) const
+{
+       CLeashFrame::Dump(dc);
+}
+
+#endif //_DEBUG
+
+/////////////////////////////////////////////////////////////////////////////
+// CMainFrame message handlers
+
+void CMainFrame::OnResetWindowSize()
+{
+    WINDOWPLACEMENT wndpl;
+       wndpl.length = sizeof(WINDOWPLACEMENT);
+
+    if (!GetWindowPlacement(&wndpl))
+    {
+        MessageBox("There is a problem getting Leash Window size!",
+                   "Error", MB_OK);
+        return;
+    }
+
+    wndpl.rcNormalPosition = CLeashFrame::s_rectDefault;
+
+       m_whatSide = SKIP_MINSIZE;
+
+    if (!SetWindowPlacement(&wndpl))
+    {
+        MessageBox("There is a problem setting Leash Window size!",
+                   "Error", MB_OK);
+    }
+
+       m_whatSide = RESET_MINSIZE;
+}
+
+void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
+{ // Keeps track of Leash window size for function CMainFrame::RecalcLayout
+       m_winRectLeft = pRect->left;
+       m_winRectTop = pRect->top;
+       m_winRectRight = pRect->right;
+       m_winRectBottom = pRect->bottom;
+
+       if (m_whatSide)
+         m_whatSide = fwSide;
+
+       CLeashFrame::OnSizing(fwSide, pRect);
+}
+
+void CMainFrame::RecalcLayout(BOOL bNotify)
+{ // MINSIZE - Insurance that we have a minimum Leash window size
+       int width = MIN_RIGHT - MIN_LEFT;
+       int height = MIN_BOTTOM - MIN_TOP;
+
+    BOOL change = FALSE;
+       WINDOWPLACEMENT wndpl;
+       wndpl.length = sizeof(WINDOWPLACEMENT);
+
+    if (!GetWindowPlacement(&wndpl))
+    {
+        MessageBox("There is a problem getting Leash Window size!",
+                   "Error", MB_OK);
+        return;
+    }
+
+       if (m_whatSide)
+       {
+               if ((m_winRectRight - m_winRectLeft) < width)
+               {
+                       if (m_whatSide == LEFT_SIDE) {
+                wndpl.rcNormalPosition.left = wndpl.rcNormalPosition.right - width;
+                change = TRUE;
+                       } else if (m_whatSide == RIGHT_SIDE) {
+                wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + width;
+                change = TRUE;
+            }
+               }
+               else if ((m_winRectBottom - m_winRectTop) < height)
+               {
+                       if (m_whatSide == TOP_SIDE) {
+                wndpl.rcNormalPosition.top = wndpl.rcNormalPosition.bottom - height;
+                change = TRUE;
+                       } else if (m_whatSide == BOTTOM_SIDE) {
+                wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + height;
+                change = TRUE;
+            }
+               }
+       }
+
+    if ( change ) {
+        if (!SetWindowPlacement(&wndpl))
+        {
+            MessageBox("There is a problem setting Leash Window size!",
+                        "Error", MB_OK);
+        }
+    }
+    m_isBeingResized = TRUE;
+
+    CLeashFrame::RecalcLayout(bNotify);
+}
+
+
+void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
+{
+    lpMMI->ptMinTrackSize.x = 650;
+    lpMMI->ptMinTrackSize.y = 240;
+       CLeashFrame::OnGetMinMaxInfo(lpMMI);
+}
+
+void CMainFrame::OnClose(void)
+{
+    CLeashFrame::OnClose();
+}
+
+LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+    BOOL oldMin = m_isMinimum;
+       switch(message)
+       {
+    case WM_SIZE:
+        switch ( wParam ) {
+        case SIZE_MINIMIZED:
+            m_isMinimum = TRUE;
+            break;
+        case SIZE_MAXIMIZED:
+        case SIZE_RESTORED:
+            m_isMinimum = FALSE;
+            break;
+        }
+        break;
+       }
+
+    if ( oldMin != m_isMinimum ) {
+        if ( m_isMinimum ) {
+            ShowTaskBarButton(FALSE);
+            ShowWindow(SW_HIDE);
+        }
+    }
+    return CLeashFrame::WindowProc(message, wParam, lParam);
+}
+
+/*
+void CMainFrame::OnHelp()
+{
+
+}
+*/
+
+/*
+void CMainFrame::OnContextHelp()
+{
+
+}
+*/
\ No newline at end of file
diff --git a/src/windows/leash/MainFrm.h b/src/windows/leash/MainFrm.h
new file mode 100644 (file)
index 0000000..1ccfcfd
--- /dev/null
@@ -0,0 +1,92 @@
+//     **************************************************************************************
+//     File:                   MainFrm.h
+//     By:                             Arthur David Leather
+//     Created:                12/02/98
+//     Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
+//     Description:    H file for MainFrm.cpp. Contains variables and functions
+//                                     for Leash
+//
+//     History:
+//
+//     MM/DD/YY        Inits   Description of Change
+//     12/02/98        ADL             Original
+//     **************************************************************************************
+
+
+#if !defined(AFX_MAINFRM_H__6F45AD95_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
+#define AFX_MAINFRM_H__6F45AD95_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#include "LeashFrame.h"
+
+class CMainFrame : public CLeashFrame
+{
+private:
+       int m_winRectLeft;
+       int m_winRectTop;
+       int m_winRectRight;
+       int m_winRectBottom;
+    BOOL m_bOwnerCreated;
+    CDialog m_MainFrameOwner;
+
+protected: // create from serialization only
+       CMainFrame();
+       DECLARE_DYNCREATE(CMainFrame)
+
+// Attributes
+public:
+       static int         m_whatSide;
+    static CStatusBar  m_wndStatusBar;
+       static CToolBar    m_wndToolBar;
+       static BOOL                m_isMinimum;
+    static BOOL        m_isBeingResized;
+    static CImageList  m_imageList;
+    static CImageList  m_disabledImageList;
+
+// Operations
+public:
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CMainFrame)
+       public:
+       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+       virtual void RecalcLayout(BOOL bNotify = TRUE);
+       virtual BOOL PreTranslateMessage(MSG* pMsg);
+       protected:
+       virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CMainFrame();
+#ifdef _DEBUG
+       virtual void AssertValid() const;
+       virtual void Dump(CDumpContext& dc) const;
+#endif
+    BOOL ShowTaskBarButton(BOOL bVisible);
+
+protected:  // control bar embedded members
+
+
+// Generated message map functions
+protected:
+       //{{AFX_MSG(CMainFrame)
+       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+       afx_msg void OnResetWindowSize();
+       afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
+       afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
+    afx_msg void OnClose(void);
+    //afx_msg void OnContextHelp();
+    //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MAINFRM_H__6F45AD95_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/StdAfx.cpp b/src/windows/leash/StdAfx.cpp
new file mode 100644 (file)
index 0000000..ef6942b
--- /dev/null
@@ -0,0 +1,5 @@
+// stdafx.cpp : source file that includes just the standard includes
+//     Leash.pch will be the pre-compiled header
+//     stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
diff --git a/src/windows/leash/StdAfx.h b/src/windows/leash/StdAfx.h
new file mode 100644 (file)
index 0000000..6b8d068
--- /dev/null
@@ -0,0 +1,27 @@
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#if !defined(AFX_STDAFX_H__6F45AD93_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
+#define AFX_STDAFX_H__6F45AD93_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
+
+#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdisp.h>        // MFC OLE automation classes
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                    // MFC support for Windows Common Controls
+#include "htmlhelp.h"
+
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__6F45AD93_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
diff --git a/src/windows/leash/VSroutines.c b/src/windows/leash/VSroutines.c
new file mode 100644 (file)
index 0000000..63f0b4a
--- /dev/null
@@ -0,0 +1,64 @@
+#include <windows.h>
+#include <winver.h>
+
+#if 0
+//#ifdef USE_VS
+#include <vs.h>
+
+#define ININAME        "leash.ini"
+
+int VScheckVersion(HWND hWnd, HANDLE hThisInstance)
+{
+    VS_Request         vrequest;
+    VS_Status          status;
+    BOOL               ok_to_continue;
+    HCURSOR            hcursor;
+    char               szFilename[255];
+    char               szVerQ[90];
+    char               *cp;
+    LPSTR              lpAppVersion;
+    LPSTR              lpAppName;
+    LONG FAR           *lpLangInfo;
+    DWORD              hVersionInfoID;
+    DWORD              size;
+    GLOBALHANDLE       hVersionInfo;
+    LPSTR              lpVersionInfo;
+    int                        dumint;
+    int                        retval;
+
+    GetModuleFileName(hThisInstance, (LPSTR)szFilename, 255);
+    size = GetFileVersionInfoSize((LPSTR) szFilename, &hVersionInfoID);
+    hVersionInfo = GlobalAlloc(GHND, size);
+    lpVersionInfo = GlobalLock(hVersionInfo);
+    retval = GetFileVersionInfo(szFilename, hVersionInfoID, size,
+                                lpVersionInfo);
+    retval = VerQueryValue(lpVersionInfo, "\\VarFileInfo\\Translation",
+                           (LPSTR FAR *)&lpLangInfo, &dumint);
+    wsprintf(szVerQ, "\\StringFileInfo\\%04x%04x\\",
+             LOWORD(*lpLangInfo), HIWORD(*lpLangInfo));
+    cp = szVerQ + lstrlen(szVerQ);
+    lstrcpy(cp, "ProductName");
+    retval = VerQueryValue(lpVersionInfo, szVerQ, &lpAppName, &dumint);
+    lstrcpy(cp, "ProductVersion");
+
+    retval = VerQueryValue(lpVersionInfo, szVerQ, &lpAppVersion, &dumint);
+    hcursor = SetCursor(LoadCursor((HINSTANCE)NULL, IDC_WAIT));
+    vrequest = VSFormRequest(lpAppName, lpAppVersion, ININAME, NULL, hWnd,
+                             V_CHECK_AND_LOG);
+    if ((ok_to_continue = (ReqStatus(vrequest) != V_E_CANCEL))
+        && v_complain((status = VSProcessRequest(vrequest)), ININAME))
+        WinVSReportRequest(vrequest, hWnd, "Version Server Status Report");
+    if (ok_to_continue && status == V_REQUIRED)
+        ok_to_continue = FALSE;
+    VSDestroyRequest(vrequest);
+    SetCursor(hcursor);
+    GlobalUnlock(hVersionInfo);
+    GlobalFree(hVersionInfo);
+    return(ok_to_continue);
+}
+#else
+int VScheckVersion(HWND hWnd, HANDLE hThisInstance)
+{
+    return(1);
+}
+#endif
diff --git a/src/windows/leash/reminder.h b/src/windows/leash/reminder.h
new file mode 100644 (file)
index 0000000..05dd4bd
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __REMINDER_H__
+#define __REMINDER_H__
+
+#define Stringize( L )        #L
+#define MakeString( M, L )    M(L)
+#define $LINE                 MakeString( Stringize, __LINE__ )
+#define Reminder              __FILE__ "(" $LINE ") : Reminder: "
+
+#endif
+
+//Put this in your .cpp file where ever you need it (NOTE: Don't end this statement with a ';' char)
+//i.e. -->> #pragma message(Reminder "Your message reminder here!!!")
diff --git a/src/windows/leash/res/Leash.ico b/src/windows/leash/res/Leash.ico
new file mode 100644 (file)
index 0000000..9ef4f96
Binary files /dev/null and b/src/windows/leash/res/Leash.ico differ
diff --git a/src/windows/leash/res/Leash.rc2 b/src/windows/leash/res/Leash.rc2
new file mode 100644 (file)
index 0000000..e5dbf29
--- /dev/null
@@ -0,0 +1,14 @@
+//
+// Leash.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+       #error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+#include "ver.rc"
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/src/windows/leash/res/Leash2.ico b/src/windows/leash/res/Leash2.ico
new file mode 100644 (file)
index 0000000..22f5fa4
Binary files /dev/null and b/src/windows/leash/res/Leash2.ico differ
diff --git a/src/windows/leash/res/Leash_Doc.ico b/src/windows/leash/res/Leash_Doc.ico
new file mode 100644 (file)
index 0000000..323cd61
Binary files /dev/null and b/src/windows/leash/res/Leash_Doc.ico differ
diff --git a/src/windows/leash/res/Leash_tickets_green.ico b/src/windows/leash/res/Leash_tickets_green.ico
new file mode 100644 (file)
index 0000000..0d2f04e
Binary files /dev/null and b/src/windows/leash/res/Leash_tickets_green.ico differ
diff --git a/src/windows/leash/res/Leash_tickets_orange.ico b/src/windows/leash/res/Leash_tickets_orange.ico
new file mode 100644 (file)
index 0000000..913f9c9
Binary files /dev/null and b/src/windows/leash/res/Leash_tickets_orange.ico differ
diff --git a/src/windows/leash/res/Leash_tickets_out.ico b/src/windows/leash/res/Leash_tickets_out.ico
new file mode 100644 (file)
index 0000000..7a9b377
Binary files /dev/null and b/src/windows/leash/res/Leash_tickets_out.ico differ
diff --git a/src/windows/leash/res/Leash_tickets_red.ico b/src/windows/leash/res/Leash_tickets_red.ico
new file mode 100644 (file)
index 0000000..a1eb326
Binary files /dev/null and b/src/windows/leash/res/Leash_tickets_red.ico differ
diff --git a/src/windows/leash/res/Leash_tkt_green.ico b/src/windows/leash/res/Leash_tkt_green.ico
new file mode 100644 (file)
index 0000000..3489896
Binary files /dev/null and b/src/windows/leash/res/Leash_tkt_green.ico differ
diff --git a/src/windows/leash/res/Leash_tkt_orange.ico b/src/windows/leash/res/Leash_tkt_orange.ico
new file mode 100644 (file)
index 0000000..4e3a908
Binary files /dev/null and b/src/windows/leash/res/Leash_tkt_orange.ico differ
diff --git a/src/windows/leash/res/Leash_tkt_red.ico b/src/windows/leash/res/Leash_tkt_red.ico
new file mode 100644 (file)
index 0000000..596a7bb
Binary files /dev/null and b/src/windows/leash/res/Leash_tkt_red.ico differ
diff --git a/src/windows/leash/res/Leash_toolbar.bmp b/src/windows/leash/res/Leash_toolbar.bmp
new file mode 100644 (file)
index 0000000..0293306
Binary files /dev/null and b/src/windows/leash/res/Leash_toolbar.bmp differ
diff --git a/src/windows/leash/res/Leash_user_green.ico b/src/windows/leash/res/Leash_user_green.ico
new file mode 100644 (file)
index 0000000..903616d
Binary files /dev/null and b/src/windows/leash/res/Leash_user_green.ico differ
diff --git a/src/windows/leash/res/Leash_user_orange.ico b/src/windows/leash/res/Leash_user_orange.ico
new file mode 100644 (file)
index 0000000..57075fc
Binary files /dev/null and b/src/windows/leash/res/Leash_user_orange.ico differ
diff --git a/src/windows/leash/res/Leash_user_out.ico b/src/windows/leash/res/Leash_user_out.ico
new file mode 100644 (file)
index 0000000..a4e493c
Binary files /dev/null and b/src/windows/leash/res/Leash_user_out.ico differ
diff --git a/src/windows/leash/res/Leash_user_red.ico b/src/windows/leash/res/Leash_user_red.ico
new file mode 100644 (file)
index 0000000..9627d0d
Binary files /dev/null and b/src/windows/leash/res/Leash_user_red.ico differ
diff --git a/src/windows/leash/res/address.ico b/src/windows/leash/res/address.ico
new file mode 100644 (file)
index 0000000..1c4e81f
Binary files /dev/null and b/src/windows/leash/res/address.ico differ
diff --git a/src/windows/leash/res/cursor1.cur b/src/windows/leash/res/cursor1.cur
new file mode 100644 (file)
index 0000000..048f06b
Binary files /dev/null and b/src/windows/leash/res/cursor1.cur differ
diff --git a/src/windows/leash/res/destroy.ico b/src/windows/leash/res/destroy.ico
new file mode 100644 (file)
index 0000000..fa7fa66
Binary files /dev/null and b/src/windows/leash/res/destroy.ico differ
diff --git a/src/windows/leash/res/destroy_disabled.ico b/src/windows/leash/res/destroy_disabled.ico
new file mode 100644 (file)
index 0000000..7cc6eab
Binary files /dev/null and b/src/windows/leash/res/destroy_disabled.ico differ
diff --git a/src/windows/leash/res/doghead_green.ico b/src/windows/leash/res/doghead_green.ico
new file mode 100644 (file)
index 0000000..eadc2a3
Binary files /dev/null and b/src/windows/leash/res/doghead_green.ico differ
diff --git a/src/windows/leash/res/doghead_grey.ico b/src/windows/leash/res/doghead_grey.ico
new file mode 100644 (file)
index 0000000..ffffce3
Binary files /dev/null and b/src/windows/leash/res/doghead_grey.ico differ
diff --git a/src/windows/leash/res/doghead_orange.ico b/src/windows/leash/res/doghead_orange.ico
new file mode 100644 (file)
index 0000000..ded7e14
Binary files /dev/null and b/src/windows/leash/res/doghead_orange.ico differ
diff --git a/src/windows/leash/res/doghead_red.ico b/src/windows/leash/res/doghead_red.ico
new file mode 100644 (file)
index 0000000..589b86a
Binary files /dev/null and b/src/windows/leash/res/doghead_red.ico differ
diff --git a/src/windows/leash/res/encryption.ico b/src/windows/leash/res/encryption.ico
new file mode 100644 (file)
index 0000000..65323ce
Binary files /dev/null and b/src/windows/leash/res/encryption.ico differ
diff --git a/src/windows/leash/res/import.ico b/src/windows/leash/res/import.ico
new file mode 100644 (file)
index 0000000..dd6ed29
Binary files /dev/null and b/src/windows/leash/res/import.ico differ
diff --git a/src/windows/leash/res/import_disabled.ico b/src/windows/leash/res/import_disabled.ico
new file mode 100644 (file)
index 0000000..9364bda
Binary files /dev/null and b/src/windows/leash/res/import_disabled.ico differ
diff --git a/src/windows/leash/res/key.ico b/src/windows/leash/res/key.ico
new file mode 100644 (file)
index 0000000..34bd815
Binary files /dev/null and b/src/windows/leash/res/key.ico differ
diff --git a/src/windows/leash/res/new.ico b/src/windows/leash/res/new.ico
new file mode 100644 (file)
index 0000000..6362690
Binary files /dev/null and b/src/windows/leash/res/new.ico differ
diff --git a/src/windows/leash/res/new_disabled.ico b/src/windows/leash/res/new_disabled.ico
new file mode 100644 (file)
index 0000000..3bbfa44
Binary files /dev/null and b/src/windows/leash/res/new_disabled.ico differ
diff --git a/src/windows/leash/res/password.ico b/src/windows/leash/res/password.ico
new file mode 100644 (file)
index 0000000..3c84285
Binary files /dev/null and b/src/windows/leash/res/password.ico differ
diff --git a/src/windows/leash/res/password_disabled.ico b/src/windows/leash/res/password_disabled.ico
new file mode 100644 (file)
index 0000000..d2a098b
Binary files /dev/null and b/src/windows/leash/res/password_disabled.ico differ
diff --git a/src/windows/leash/res/refresh.ico b/src/windows/leash/res/refresh.ico
new file mode 100644 (file)
index 0000000..310d924
Binary files /dev/null and b/src/windows/leash/res/refresh.ico differ
diff --git a/src/windows/leash/res/refresh_disabled.ico b/src/windows/leash/res/refresh_disabled.ico
new file mode 100644 (file)
index 0000000..a94d08b
Binary files /dev/null and b/src/windows/leash/res/refresh_disabled.ico differ
diff --git a/src/windows/leash/res/renew.ico b/src/windows/leash/res/renew.ico
new file mode 100644 (file)
index 0000000..31127c0
Binary files /dev/null and b/src/windows/leash/res/renew.ico differ
diff --git a/src/windows/leash/res/renew_disabled.ico b/src/windows/leash/res/renew_disabled.ico
new file mode 100644 (file)
index 0000000..672baed
Binary files /dev/null and b/src/windows/leash/res/renew_disabled.ico differ
diff --git a/src/windows/leash/res/sync.ico b/src/windows/leash/res/sync.ico
new file mode 100644 (file)
index 0000000..a3f0670
Binary files /dev/null and b/src/windows/leash/res/sync.ico differ
diff --git a/src/windows/leash/res/sync_disabled.ico b/src/windows/leash/res/sync_disabled.ico
new file mode 100644 (file)
index 0000000..0d806ab
Binary files /dev/null and b/src/windows/leash/res/sync_disabled.ico differ
diff --git a/src/windows/leash/resource.h b/src/windows/leash/resource.h
new file mode 100644 (file)
index 0000000..629a75c
--- /dev/null
@@ -0,0 +1,336 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Leash.rc
+//
+#define IDD_ABOUTBOX                    100
+#define IDD_TEST2_FORM                  102
+#define ID_HELLO_WORLD                  114
+#define IDR_MAINFRAME                   128
+#define IDR_LeashTYPE                   129
+#define IDD_DIALOG1                     130
+#define IDD_FORMVIEW                    130
+#define IDD_LEASH_FORMVIEW              130
+#define IDI_TICKET_EXPIRED              141
+#define IDI_LEASH                       143
+#define IDI_TICKETTYPE_GOOD             144
+#define IDI_TICKET_GOOD                 145
+#define IDI_TICKET_LOW                  146
+#define IDI_TICKETTYPE_NOTINSTALLED     147
+#define IDI_TICKETTYPE_EXPIRED          148
+#define IDI_TICKETTYPE_LOW              149
+#define IDD_LEASH_ABOUTBOX              153
+#define IDD_DIALOG2                     154
+#define IDD_MESSAGE_BOX                 154
+#define IDD_LEASH_MESSAGE_BOX           154
+#define IDD_DIALOG3                     155
+#define IDD_DIALOG4                     156
+#define IDD_DEBUG_WINDOW                157
+#define IDD_LEASH_DEBUG_WINDOW          157
+#define IDD_PAGE1                       160
+#define IDD_KRB4_PROP_LOCATION          160
+#define IDD_PAGE2                       161
+#define IDD_KRB4_PROP_CONTENT           161
+#define IDD_KRB_PROP_CONTENT            161
+#define IDD_LEASH_PROPERTIES            167
+#define IDD_KERB5_PAGE_PROP             168
+#define IDD_KRB5_PROP_CONTENT           168
+#define IDD_KRB5_PROP_LOCATION          169
+#define IDD_KRB4_REALMHOST_MAINT        178
+#define IDD_KRB_REALMHOST_MAINT         178
+#define IDC_CURSOR1                     179
+#define IDD_KRB4_DOMAINREALM_MAINT      180
+#define IDD_KRB4_ADD_REALMHOSTNAMES     181
+#define IDD_KRB_ADD_REALM               181
+#define IDD_KRB4_EDIT_REALMHOSTNAMES    182
+#define IDD_KRB_EDIT_REALM              182
+#define IDD_KRB4_ADD_DOMAINREALMNAME    183
+#define IDD_KRB4_EDIT_DOMAINREALMNAME   184
+#define IDD_DIALOG5                     187
+#define IDD_KRB_ADD_KDC_HOSTSERVER      197
+#define IDD_KRB_EDIT_KDC_HOSTSERVER     199
+#define IDD_KRB4_REALMHOST_MAINT2       203
+#define IDD_KRB4_EDIT_REALM             204
+#define IDD_KRB4_ADD_REALM              205
+#define IDD_DIALOG6                     207
+#define IDD_KRB_DOMAINREALM_MAINT       207
+#define IDD_DIALOG7                     210
+#define IDI_ICON1                       221
+#define IDD_AFS_PROPERTIES              224
+#define IDD_AUTHENTICATE                229
+#define IDI_LEASH_PRINCIPAL_GOOD        230
+#define IDI_LEASH_PRINCIPAL_LOW         231
+#define IDI_LEASH_PRINCIPAL_EXPIRED     232
+#define IDI_LEASH_PRINCIPAL_NONE        233
+#define IDB_BITMAP1                     239
+#define IDI_TOOLBAR_INIT                240
+#define IDI_TOOLBAR_RENEW               241
+#define IDI_TOOLBAR_IMPORT              242
+#define IDI_TOOLBAR_DESTROY             243
+#define IDI_TOOLBAR_PASSWORD            244
+#define IDI_TOOLBAR_REFRESH             245
+#define IDI_TOOLBAR_SYNC                246
+#define IDI_TOOLBAR_INIT_DISABLED       247
+#define IDI_TOOLBAR_RENEW_DISABLED      248
+#define IDI_TOOLBAR_IMPORT_DISABLED     249
+#define IDI_TOOLBAR_DESTROY_DISABLED    250
+#define IDI_TOOLBAR_PASSWORD_DISABLED   251
+#define IDI_TOOLBAR_REFRESH_DISABLED    252
+#define IDI_TOOLBAR_SYNC_DISABLED       253
+#define MENU_TRAYICON                   254
+#define ID_LEASH_RESTORE                255
+#define IDD_FRAMEOWNER                  256
+#define ID_LEASH_MINIMIZE               257
+#define IDI_LEASH_TRAY_GOOD             258
+#define IDI_LEASH_TRAY_LOW              259
+#define IDI_LEASH_TRAY_EXPIRED          260
+#define IDI_LEASH_TRAY_NONE             261
+#define IDI_LEASH_TICKET_ADDRESS        262
+#define IDI_LEASH_TICKET_SESSION        263
+#define IDI_LEASH_TICKET_ENCRYPTION     264
+#define IDC_PROGRESS1                   1000
+#define IDC_TRACKBAR1                   1001
+#define IDC_TRACKBAR2                   1002
+#define IDC_BUDDY_SPIN1                 1003
+#define IDC_SPIN1                       1004
+#define IDC_LISTVIEW1                   1005
+#define IDC_TREEVIEW1                   1006
+#define IDC_TREEVIEW                    1006
+#define IDC_STATIC_TRACK1               1007
+#define IDC_STATIC_TRACK2               1008
+#define IDC_STATIC_LISTVIEW1            1009
+#define IDC_STATIC_TREEVIEW1            1010
+#define IDC_LABEL_KERB_TICKETS          1011
+#define IDC_LIST1                       1012
+#define IDC_LEASH_MODULE_LB             1012
+#define IDC_LIST_KRB4_REALM_HOST        1012
+#define IDC_LIST_UTILITY                1012
+#define IDC_LIST_KDC_REALM              1012
+#define IDC_LIST_REMOVE_HOST            1012
+#define IDC_LISTBOX_DLL_LOADED          1013
+#define IDC_STATIC_ABOUTBOX_LEASH       1014
+#define IDC_STATIC_VERSION              1015
+#define IDC_STATIC_COPYRIGHT            1016
+#define IDC_STATIC_MODULES_LOADED       1018
+#define IDC_LEASH_WARNING_MSG           1019
+#define IDC_DEBUG_LISTBOX               1022
+#define IDC_COPY_TO_CLIPBOARD           1023
+#define IDC_LOG_FILE_LOCATION_LABEL     1024
+#define IDC_LOG_FILE_LOCATION_TEXT      1025
+#define IDC_LEASH_MODULES               1029
+#define IDC_ALL_MODULES                 1030
+#define IDC_PROPERTIES                  1031
+#define IDC_STATIC_NO_OF_MODULES        1036
+#define IDC_BUTTON_LEASHINI_DETAILS     1037
+#define IDC_BUTTON_LEASHINI_HELP        1037
+#define IDC_STATIC_LEASHINI_LOCATION    1038
+#define IDC_BUTTON_LEASHINI_HELP2       1039
+#define IDC_EDIT_LEASHINI               1040
+#define IDC_EDIT_KRB_LOCATION           1041
+#define IDC_EDIT_KRBREALM_LOCATION      1042
+#define IDC_STATIC_KRBCON_LOCATION      1043
+#define IDC_STATIC_KRBREALM_LOCATION    1044
+#define IDC_EDIT_KRB_KRBREALM_LOC       1045
+#define IDC_EDIT_KRB_LOC                1045
+#define IDC_EDIT_KRBREALM_LOC           1046
+#define IDC_BUTTON_KRB_BROWSE           1047
+#define IDC_BUTTON_KRBREALM_BROWSE      1048
+#define IDC_STATIC_LEASH                1049
+#define IDC_STATIC_KRB                  1050
+#define IDC_EDITKRB5_LOCATION           1051
+#define IDC_STATIC_KRB5_LOCATION        1052
+#define IDC_STATIC_KRB5INI_LOCATION     1052
+#define IDC_BUTTON_KRB_DETAILS          1053
+#define IDC_BUTTON_KRBFILES_HELP        1053
+#define IDC_BUTTON_KRBTKT_HELP          1054
+#define IDC_STATIC_NDIR                 1055
+#define IDC_EDIT_NDIR                   1056
+#define IDC_STATIC_LEASH_PROPERTIES     1057
+#define IDC_STATIC_DEFAULT_REALM        1058
+#define IDC_EDIT_DEFAULT_REALM          1059
+#define IDC_EDIT_REALM_HOSTNAME         1060
+#define IDC_RADIO_ADMIN_SERVER          1062
+#define IDC_RADIO_NO_ADMIN_SERVER       1063
+#define IDC_EDIT_KRBTKFILE              1064
+#define IDC_STATIC_KRBTKFILE            1065
+#define IDC_NOT_LOADED_MODULES          1066
+#define IDC_STATIC_TICKET_FILE          1067
+#define IDC_EDIT_TICKET_FILE            1068
+#define IDC_STATIC_KRB5_TICKET_FILE     1068
+#define IDC_BUTTON_TICKETFILE_BROWSE    1069
+#define IDC_EDIT_KRB5_TXT_FILE          1069
+#define IDC_STATIC_CONFIG_FILES         1070
+#define IDC_BUTTON_KRB5_TICKETFILE_BROWSE 1070
+#define IDC_STATIC_TICKETFILE           1071
+#define IDC_CHECK_PROXIABLE             1073
+#define IDC_CHECK_FORWARDABLE           1074
+#define IDC_EDIT_KRB5INI_LOCATION       1076
+#define IDC_BUTTON_KRB5INI_BROWSE       1077
+#define IDC_BUTTON_KRB5INI_HELP         1078
+#define IDC_STATIC__KRB5_TICKETFILE     1079
+#define IDC_BUTTON_KRB5TKT_HELP         1080
+#define IDC_EDIT_TIME_SERVER            1081
+#define IDC_STATIC_TIMESERVER           1082
+#define IDC_STATIC_OPTIONS              1083
+#define IDC_STATIC_TICKET_OPTIONS       1085
+#define IDC_BUTTON1                     1086
+#define IDC_BUTTON_AFS_PROPERTIES       1086
+#define IDC_RESET_DEFAULTS              1086
+#define IDC_BUTTON_KRB_HELP             1087
+#define IDC_STATIC_KRBREALM             1088
+#define IDC_BUTTON_KRBREALM_HELP        1089
+#define IDC_STATIC_HOST                 1092
+#define IDC_STATIC_DOMAIN               1093
+#define IDC_EDIT_HOSTNAME               1096
+#define IDC_EDIT_DOMAINNAME             1097
+#define IDC_STATIC_REALM_HOSTNAME       1098
+#define ID_BUTTON_HOSTNAME_REMOVE       1100
+#define IDC_STATIC_CFG_LOCATION         1103
+#define IDC_BUTTON_HOSTNAME_ADD         1104
+#define IDC_BUTTON_HOSTMAINT_HELP       1105
+#define IDC_BUTTON_HOSTNAME_EDIT        1106
+#define IDC_STATIC_HAS_ADMINSERVER_     1107
+#define IDC_STATIC_NO_ADMINSERVER       1108
+#define IDC_BUTTON_REALM_HOST_ADD       1110
+#define ID_BUTTON_REALM_HOST_REMOVE     1111
+#define ID_BUTTON_REALM_REMOVE          1111
+#define IDC_BUTTON_REALM_HOST_EDIT      1112
+#define IDC_BUTTON_REALM_EDIT           1112
+#define IDC_BUTTON_REALMHOST_MAINT_HELP 1113
+#define IDC_EDIT_DOMAINHOSTNAME         1115
+#define IDC_LIST_DOMAINREALM            1116
+#define IDC_EDIT_DOMAINHOST             1117
+#define IDC_BUTTON_KDCHOST_ADD          1117
+#define IDC_EDIT_REALMNAME              1118
+#define IDC_BUTTON_KDCHOST_REMOVE       1118
+#define stc32                           0x045f
+#define IDC_EDIT_DOMAINREALMNAME        1119
+#define IDC_BUTTON_KDCHOST_EDIT         1119
+#define IDC_STATIC_TICKET_FILEPATH      1120
+#define IDC_LIST_KDC_HOST               1123
+#define IDC_STATIC_REALM                1124
+#define IDC_BUTTON_ADMINSERVER          1125
+#define IDC_BUTTON_REMOVE_ADMINSERVER   1126
+#define IDC_STATIC_NOTE                 1129
+#define IDC_EDIT_KDC_HOST               1130
+#define IDC_EDIT_REALM                  1131
+#define IDC_BUTTON_KRB4_REALM_HOST_ADD  1133
+#define ID_BUTTON_KRB4_REALM_HOST_REMOVE 1134
+#define IDC_BUTTON_KRB4_REALM_HOST_EDIT 1135
+#define IDC_BUTTON_REALMHOST_MAINT_HELP2 1136
+#define IDC_BUTTON_HOST_ADD             1138
+#define ID_BUTTON_HOST_REMOVE           1139
+#define IDC_BUTTON_HOST_EDIT            1140
+#define IDC_STATIC_KRBCON               1141
+#define IDC_STATIC_KRBCON_LABEL         1142
+#define IDC_STATIC_KRBREALM_LABEL       1143
+#define IDC_STATIC_TXT                  1145
+#define IDC_STATIC_TIMEHOST             1147
+#define IDC_STATIC_CONFILES             1148
+#define IDC_STATIC_KRBREALMS            1149
+#define IDC_STATIC_INIFILES             1150
+#define IDC_CHECK_CONFIRM_KRB5_EXISTS   1151
+#define IDC_RADIO_AFS_ENABLED           1152
+#define IDC_RADIO_AFS_DISABLED          1153
+#define IDC_STATIC_KRB_DEFAULT_LIFETIME 1154
+#define IDC_STATIC_TIME_UNITS           1155
+#define IDC_STATIC_KRB_DEFAULT_RENEWTILL 1155
+#define IDC_EDIT_DEFAULT_LIFETIME       1156
+#define IDC_ABOUT_COPYRIGHT             1158
+#define IDC_ABOUT_VERSION               1159
+#define IDC_CHECK_RENEWABLE             1159
+#define IDC_CHECK_NO_ADDRESS            1160
+#define IDC_IPADDRESS_PUBLIC            1162
+#define IDC_STATIC_IPADDR               1163
+#define IDC_STATIC_NAME                 1164
+#define IDC_STATIC_PWD                  1165
+#define IDC_EDIT1                       1166
+#define IDC_EDIT_LIFE_MIN_D             1166
+#define IDC_COMBO1                      1167
+#define IDC_EDIT_LIFETIME_D             1167
+#define IDC_EDIT2                       1168
+#define IDC_EDIT_LIFE_MIN_H             1168
+#define IDC_STATIC_LIFETIME             1169
+#define IDC_EDIT_RENEWTILL_D            1169
+#define IDC_SLIDER1                     1170
+#define IDC_EDIT_LIFETIME_H             1170
+#define IDC_STATIC_KRB5                 1171
+#define IDC_EDIT_RENEWTILL_H            1171
+#define IDC_CHECK1                      1172
+#define IDC_CHECK_REQUEST_KRB4          1172
+#define IDC_CHECK2                      1173
+#define IDC_CHECK_PRESERVE_KINIT_OPTIONS 1173
+#define IDC_CHECK3                      1174
+#define IDC_SLIDER2                     1175
+#define IDC_STATIC_LIFETIME_VALUE       1176
+#define IDC_STATIC_RENEW_TILL_VALUE     1177
+#define IDC_PICTURE                     1179
+#define IDC_DNS_KDC                     1180
+#define IDC_KRB4_DNS_KDC                1181
+#define IDC_CHECK_CREATE_MISSING_CFG    1182
+#define IDC_GROUP_LEASH_MISC            1183
+#define IDC_STATIC_LIFETIME_RANGE       1184
+#define IDC_STATIC_RENEW_TILL_RANGE     1185
+#define IDC_EDIT_LIFE_MIN_M             1190
+#define IDC_EDIT_LIFE_MAX_D             1191
+#define IDC_EDIT_LIFE_MAX_H             1192
+#define IDC_EDIT_LIFE_MAX_M             1193
+#define IDC_STATIC_LIFE_RANGE_MIN       1194
+#define IDC_EDIT_RENEW_MIN_D            1195
+#define IDC_EDIT_RENEW_MIN_H            1196
+#define IDC_EDIT_RENEW_MIN_M            1197
+#define IDC_EDIT_RENEW_MAX_D            1198
+#define IDC_EDIT_RENEW_MAX_H            1199
+#define IDC_EDIT_RENEW_MAX_M            1200
+#define IDC_EDIT_LIFETIME_M             1201
+#define IDC_EDIT_RENEWTILL_M            1202
+#define IDC_RADIO_MSLSA_IMPORT_OFF      1203
+#define IDC_RADIO_MSLSA_IMPORT_ON       1204
+#define IDC_RADIO_MSLSA_IMPORT_MATCH    1205
+#define IDC_STATIC_LEASH_MSLSA          1206
+#define IDD_FILESPECIAL                 1536
+#define IDD_LEASH_FILESPECIAL           1536
+#define IDD_KRB_PROP_MISC               1537
+#define ID_RENEW_TICKET                 32776
+#define ID_DESTROY_TICKET               32777
+#define ID_SYN_TIME                     32778
+#define ID_CHANGE_PASSWORD              32779
+#define ID_UPDATE_DISPLAY               32780
+#define ID_DEBUG_MODE                   32781
+#define ID_CFG_FILES                    32782
+#define ID_HELP_LEASH_                  32783
+#define ID_HELP_KERBEROS_               32784
+#define ID_KILL_TIX_ONEXIT              32785
+#define ID_LARGE_ICONS                  32786
+#define ID_UPPERCASE_REALM              32787
+#define ID_OPTIONS_RESETWINDOWSIZE      32789
+#define ID_RESET_WINDOW_SIZE            32790
+#define ID_AFS_CONTROL_PANEL            32791
+#define ID_SYSTEM_CONTROL_PANEL         32792
+#define ID_KRB4_PROPERTIES              32793
+#define ID_KRB5_PROPERTIES              32794
+#define ID_LEASH_PROPERTIES             32795
+#define ID_OPTIONS_LOWTICKETALARMSOUND  32796
+#define ID_LOW_TICKET_ALARM             32798
+#define ID_KRBCHECK                     32799
+#define ID_PROPERTIES                   32801
+#define ID_NEW_ITEM                     32802
+#define ID_HELP_CONTENTS                32803
+#define ID_HELP_FIND                    32803
+#define ID_HELP_LEASH32                 32804
+#define ID_HELP_WHYUSELEASH32           32805
+#define ID_IMPORT_TICKET                32806
+#define ID_INIT_TICKET                  32807
+#define ID_AUTO_RENEW                   32808
+#define ID_OBTAIN_TGT_WITH_LPARAM       32809
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_3D_CONTROLS                     1
+#define _APS_NEXT_RESOURCE_VALUE        241
+#define _APS_NEXT_COMMAND_VALUE         32810
+#define _APS_NEXT_CONTROL_VALUE         1207
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif