windows-server-manager-20050509
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 10 May 2005 04:33:28 +0000 (04:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 10 May 2005 04:33:28 +0000 (04:33 +0000)
Enable KFW support for server manager

src/WINNT/afsapplib/al_admsvr.cpp
src/WINNT/afsapplib/al_creds.cpp
src/WINNT/afsapplib/al_misc.cpp
src/WINNT/afssvrmgr/creds.cpp

index c2d672b..ef8fb54 100644 (file)
@@ -25,7 +25,7 @@ static struct
    {
    BOOL fUseAdminServer;
    DWORD idAdminServerClient;
-   } l;
+   } l = {0, 0};
 
 
 /*
index 237a606..f2f964d 100644 (file)
@@ -68,7 +68,8 @@ BOOL AfsAppLib_CrackCredentials (PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, L
       {
       rc = asc_CredentialsCrack (idClient, hCreds, pszCell, pszUser, pst, &status);
       }
-   else if (OpenClientLibrary())
+   else 
+       if (OpenClientLibrary())
       {
       char szUserA[ cchRESOURCE ], szUser2A[ cchRESOURCE ];
       char szCellA[ cchRESOURCE ];
@@ -102,7 +103,8 @@ PVOID AfsAppLib_GetCredentials (LPCTSTR pszCell, ULONG *pStatus)
       {
       hCreds = asc_CredentialsGet (idClient, pszCell, &status);
       }
-   else if (OpenClientLibrary())
+   else
+       if (OpenClientLibrary())
       {
       LPSTR pszCellA = StringToAnsi (pszCell);
 
@@ -128,7 +130,8 @@ PVOID AfsAppLib_SetCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPas
       {
       hCreds = asc_CredentialsSet (idClient, pszCell, pszUser, pszPassword, &status);
       }
-   else if (OpenClientLibrary())
+   else
+       if (OpenClientLibrary())
       {
       char szCellA[ cchRESOURCE ];
       char szUserA[ cchRESOURCE ];
@@ -903,6 +906,9 @@ void OnExpiredCredentials (WPARAM wp, LPARAM lp)
 
 BOOL AfsAppLib_IsUserAdmin (PVOID hCreds, LPTSTR pszUser)
 {
+#ifndef USE_KASERVER
+    return TRUE;
+#else
    BOOL rc = FALSE;
    afs_status_t status;
 
@@ -969,5 +975,6 @@ BOOL AfsAppLib_IsUserAdmin (PVOID hCreds, LPTSTR pszUser)
       }
 
    return rc;
+#endif /* USE_KASERVER */
 }
 
index 3620bd2..438c6f6 100644 (file)
@@ -213,7 +213,8 @@ BOOL CALLBACK AfsAppLib_TranslateErrorFunc (LPTSTR pszText, ULONG code, LANGID i
       ULONG status;
       return asc_ErrorCodeTranslate (idClient, code, idLanguage, pszText, &status);
       }
-   else if (OpenUtilLibrary())
+   else
+       if (OpenUtilLibrary())
       {
       const char *pszTextA = NULL;
       afs_status_t status;
@@ -463,7 +464,8 @@ BOOL AfsAppLib_GetLocalCell (LPTSTR pszCell, ULONG *pStatus)
          {
          rc = asc_LocalCellGet (idClient, szCell, &status);
          }
-      else if (OpenClientLibrary())
+      else 
+          if (OpenClientLibrary())
          {
          char szCellNameA[ MAX_PATH ];
          if ((rc = afsclient_LocalCellGet (szCellNameA, (afs_status_p)&status)) == TRUE)
index 0ad004e..b7cc625 100644 (file)
@@ -18,6 +18,7 @@ extern "C" {
 #include "time.h"
 #include "subset.h"
 
+#include <afs\afskfw.h>
 
 /*
  * OPENCELL DIALOG ____________________________________________________________
@@ -91,28 +92,53 @@ void OpenCellDlg_Hook_OnOK (HWND hDlg, LPOPENCELLDLG_PARAMS lpp)
    TCHAR szPassword[ cchRESOURCE ];
    GetDlgItemText (hDlg, IDC_OPENCELL_PASSWORD, szPassword, cchNAME);
 
-   ULONG status;
-   if ((lpp->hCreds = AfsAppLib_SetCredentials (lpp->szCell, szUser, szPassword, &status)) == NULL)
-      {
-      ErrorDialog (status, IDS_SVR_ERROR_BAD_CREDENTIALS);
-      }
-   else
-      {
-      // See if those credentials are sufficient
-      //
-      CHECKCREDS_PARAMS pp;
-      memset (&pp, 0x00, sizeof(pp));
-      memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
-      pp.bcdp.hParent = hDlg;
-      pp.hCreds = lpp->hCreds;
-      pp.fShowWarning = TRUE;
-
-      if ((rc = AfsAppLib_CheckCredentials (&pp)) == FALSE)
-         {
-         SetDlgItemText (hDlg, IDC_OPENCELL_ID, TEXT("admin"));
-         PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_OPENCELL_PASSWORD), TRUE);
-         }
-      }
+    ULONG status;
+
+    if ( KFW_is_available() ) {
+        // KFW_AFS_get_cred() parses the szNameA field as complete 
+        // princial including potentially
+        // a different realm then the specified cell name.
+        char *Result = NULL;
+        
+        char szCellA[ 256 ];
+        CopyStringToAnsi (szCellA, lpp->szCell);
+
+        char szUserA[ 256 ];
+        CopyStringToAnsi (szUserA, szUser);
+
+        char szPasswordA[ 256 ];
+        CopyStringToAnsi (szPasswordA, szPassword);
+
+        rc = !KFW_AFS_get_cred(szUserA, szCellA, szPasswordA, 0, NULL, &Result);
+        if (rc) {
+            if ((lpp->hCreds = AfsAppLib_GetCredentials (lpp->szCell, &status)) == NULL) {
+                ErrorDialog (status, IDS_SVR_ERROR_BAD_CREDENTIALS);
+            }
+        }
+    } else {
+        if ((lpp->hCreds = AfsAppLib_SetCredentials (lpp->szCell, szUser, szPassword, &status)) == NULL)
+        {
+            ErrorDialog (status, IDS_SVR_ERROR_BAD_CREDENTIALS);
+        }
+        else
+        {
+            // See if those credentials are sufficient
+            //
+            CHECKCREDS_PARAMS pp;
+            memset (&pp, 0x00, sizeof(pp));
+            memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
+            pp.bcdp.hParent = hDlg;
+            pp.hCreds = lpp->hCreds;
+            pp.fShowWarning = TRUE;
+
+            if ((rc = AfsAppLib_CheckCredentials (&pp)) == FALSE)
+            {
+                SetDlgItemText (hDlg, IDC_OPENCELL_ID, TEXT("admin"));
+                PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_OPENCELL_PASSWORD), TRUE);
+            }
+        }
+
+    }
 
    if (rc)
       {