示例#1
0
UINT_PTR AfsAppLib_SetCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus)
{
   UINT_PTR hCreds = 0;
   ULONG status = 0;

   UINT_PTR idClient;
   if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
      {
      hCreds = asc_CredentialsSet (idClient, pszCell, pszUser, pszPassword, &status);
      }
   else
       if (OpenClientLibrary())
      {
      char szCellA[ cchRESOURCE ];
      char szUserA[ cchRESOURCE ];
      char szPasswordA[ cchRESOURCE ];
      CopyStringToAnsi (szCellA, pszCell);
      CopyStringToAnsi (szUserA, pszUser);
      CopyStringToAnsi (szPasswordA, pszPassword);

      afsclient_TokenGetNew (szCellA, szUserA, szPasswordA, (PVOID *)&hCreds, (afs_status_p)&status);

      CloseClientLibrary();
      }

   if (hCreds)
      {
      PostMessage (AfsAppLib_GetMainWindow(), WM_REFRESHED_CREDENTIALS, 0, (LPARAM)hCreds);
      }

   if (!hCreds && pStatus)
      *pStatus = status;
   return hCreds;
}
示例#2
0
void AfsClass_SplitFilename (LPSTR pszDirectoryA, LPSTR pszFilenameA, LPTSTR pszFullName)
{
   CopyStringToAnsi (pszDirectoryA, pszFullName);

   LPSTR pszLastSlashA = NULL;
   for (LPSTR pszA = pszDirectoryA; *pszA; ++pszA)
      {
      if ((*pszA == '/') || (*pszA == '\\'))
         pszLastSlashA = pszA;
      }

   if (!pszLastSlashA)
      {
      strcpy (pszFilenameA, pszDirectoryA);
      *pszDirectoryA = 0;
      }
   else
      {
      strcpy (pszFilenameA, 1+pszLastSlashA);
      *pszLastSlashA = 0;
      }
}
示例#3
0
void EnumeratePrincipalsLocally (LPBROWSEDIALOGPARAMS pbdp)
{
   ULONG status;

   char szCellA[ MAX_PATH ];
   CopyStringToAnsi (szCellA, pbdp->szCell);

   PVOID hCell;
   if (afsclient_CellOpen (szCellA, (PVOID)pbdp->hCreds, &hCell, (afs_status_p)&status))
   {
      // Enumerate the principals recognized by KAS.
      //
      PVOID hEnum;
      if (kas_PrincipalGetBegin (hCell, NULL, &hEnum, (afs_status_p)&status))
      {
         pbdp->fCanStopThreadEasily = TRUE;

         while (!pbdp->fShouldStopThread)
         {
            kas_identity_t who;
            if (!kas_PrincipalGetNext (hEnum, &who, (afs_status_p)&status))
               break;

            LPTSTR pszName;
            if ((pszName = CloneAnsi ((LPSTR)who.principal)) == NULL)
               break;

            PostMessage (pbdp->hDlg, WM_FOUNDNAME, 0, (LPARAM)pszName);
            // pszName freed by DlgProc_Browse when it receives the message
         }

         kas_PrincipalGetDone (hEnum, (afs_status_p)&status);
      }

      afsclient_CellClose (hCell, (afs_status_p)&status);
   }
}
示例#4
0
BOOL AfsAppLib_IsUserAdmin (UINT_PTR hCreds, LPTSTR pszUser)
{
#ifndef USE_KASERVER
    return TRUE;
#else
   BOOL rc = FALSE;
   afs_status_t status;

   UINT_PTR idClient;
   if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
      {
      TCHAR szCell[ cchRESOURCE ];
      TCHAR szUser[ cchRESOURCE ];
      SYSTEMTIME stExpire;
      if (asc_CredentialsCrack (idClient, hCreds, szCell, szUser, &stExpire, (ULONG*)&status))
         {
         ASID idCell;
         if (asc_CellOpen (idClient, hCreds, szCell, AFSADMSVR_SCOPE_USERS, &idCell, (ULONG*)&status))
            {
            ASID idUser;
            if (asc_ObjectFind (idClient, idCell, TYPE_USER, pszUser, &idUser, (ULONG*)&status))
               {
               ASOBJPROP Info;
               if (asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Info, (ULONG*)&status))
                  {
                  if (Info.u.UserProperties.fHaveKasInfo)
                     {
                     rc = Info.u.UserProperties.KASINFO.fIsAdmin;
                     }
                  }
               }
            asc_CellClose (idClient, idCell, (ULONG*)&status);
            }
         }
      }
   else if (OpenClientLibrary())
      {
      if (OpenKasLibrary())
         {
         char szUserA[ cchRESOURCE ], szUser2A[ cchRESOURCE ];
         char szCellA[ cchRESOURCE ];
         unsigned long dateExpire;
         int fHasKasToken;

         if (afsclient_TokenQuery (hCreds, &dateExpire, szUserA, szUser2A, szCellA, &fHasKasToken, (afs_status_p)&status))
            {
            PVOID hCell;
            if (afsclient_CellOpen (szCellA, hCreds, &hCell, &status))
               {
               kas_identity_t Identity;
               memset (&Identity, 0x00, sizeof(Identity));
               CopyStringToAnsi (Identity.principal, pszUser);

               kas_principalEntry_t Entry;
               if (kas_PrincipalGet (hCell, NULL, &Identity, &Entry, &status))
                  {
                  if (Entry.adminSetting == KAS_ADMIN)
                     rc = TRUE;
                  }

               afsclient_CellClose (hCell, (afs_status_p)&status);
               }
            }

         CloseKasLibrary();
         }

      CloseClientLibrary();
      }

   return rc;
#endif /* USE_KASERVER */
}