Пример #1
0
/**
 * Begin the process of getting the KAS users, starting at
 * startIndex, that belong to the cell.  
 * Returns an iteration ID to be used by subsequent calls to 
 * getKasUsersNextString (or getKasUsersNext) 
 * and getKasUsersDone.
 *
 *  env      the Java environment
 *  cls      the current Java class
 *  cellHandle    the handle of the cell to which the users belong
 *  startIndex    the starting base-zero index
 *  returns an iteration ID
 */
JNIEXPORT jlong JNICALL 
Java_org_openafs_jafs_Cell_getKasUsersBeginAt (JNIEnv *env, jclass cls, 
						  jlong cellHandle, 
						  jint startIndex) {

  afs_status_t ast;
  void *iterationId;
  kas_identity_t who;
  int i;

  if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, 
			      &iterationId, &ast ) ) {
    throwAFSException( env, ast );
    return;
  }

  for ( i = 1; i < startIndex; i++) {
    if( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
      if( ast == ADMITERATORDONE ) {
        return 0;
      } else {
        throwAFSException( env, ast );
        return 0;
      }
    }
  }

  return (jlong) iterationId;

}
Пример #2
0
/**
 * Begin the process of getting the kas users that belong to the cell.  
 * Returns an iteration ID to be used by subsequent calls to 
 * getKasUsersNextString (or getKasUsersNext) 
 * and getKasUsersDone.
 *
 *  env      the Java environment
 *  cls      the current Java class
 *  cellHandle    the handle of the cell to which the users belong
 *  returns an iteration ID
 */
JNIEXPORT jlong JNICALL 
Java_org_openafs_jafs_Cell_getKasUsersBegin (JNIEnv *env, jclass cls, 
						jlong cellHandle) {

  afs_status_t ast;
  void *iterationId;

  if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, &iterationId, 
			      &ast ) ) {
    throwAFSException( env, ast );
    return;
  }

  return (jlong) iterationId;

}
Пример #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
/**
 * Returns the total number of KAS users belonging to the cell denoted
 * by cellHandle.
 *
 *  env      the Java environment
 *  cls      the current Java class
 *  cellHandle    the handle of the cell to which the users belong
 *  returns total count of KAS users
 */
JNIEXPORT jint JNICALL 
Java_org_openafs_jafs_Cell_getKasUserCount (JNIEnv *env, jclass cls, 
					       jlong cellHandle) {

  afs_status_t ast;
  void *iterationId;
  kas_identity_t who;
  int i = 0;

  if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, 
			      &iterationId, &ast ) ) {
    throwAFSException( env, ast );
    return -1;
  }

  while ( kas_PrincipalGetNext( iterationId, &who, &ast ) ) i++;

  if( ast != ADMITERATORDONE ) {
    throwAFSException( env, ast );
    return -1;
  }

  return i;
}