midrange.com code scratchpad
Name:
Monty James
Scriptlanguage:
C++
Tabwidth:
4
Date:
03/25/2019 09:51:06 pm
IP:
Logged
Description:
Delete EIM Identifier and Associations related to target ID
Code:
  1. #include <eim.h>                   
  2. #include <stdio.h>                 
  3. #include <errno.h>                 
  4.                                    
  5. int main (int argc, char * argv[]) 
  6. {                                  
  7.     int   rc;                      
  8.     char  eimerr[200];             
  9.     EimRC      * err;              
  10.     EimHandle  handle;             
  11.     EimIdentifierInfo x;           
  12.     EimConnectInfo con;            
  13.     char  unique[30];              
  14.     char  rtnstr[20];              
  15.     char       * message;          
  16.     unsigned int sizeOfUnique = 30;
  17.                                    
  18.     /* error structure */          
  19.     memset (eimerr,0x00,200);      
  20.     err = (EimRC *)eimerr; 
  21.     err->memoryProvidedByCaller = 200;                               
  22.                                                                      
  23.     /* Create new eim handle. */                                     
  24.     if (0 != (rc = eimCreateHandle(&handle,                          
  25.                                     NULL,                            
  26.                                     err)))                           
  27.                                                                      
  28.     {                                                                
  29.        message = eimErr2String(err);                                 
  30.        sprintf(argv[4], "EIM API Handle Error Message: %s", message);
  31.        free(message);                                                
  32.                                                                      
  33.        /*replace the NULL terminator with a space */                 
  34.        argv[4] [strlen(argv[4])] = ' ';                              
  35.        return -1;                                                    
  36.     }                                                                
  37.                                                                      
  38.     /* connection information */                                     
  39.     con.type = EIM_SIMPLE;                                           
  40.     con.creds.simpleCreds.protect = EIM_PROTECT_NO;                  
  41.     con.creds.simpleCreds.bindDn = argv[2]; 
  42.     con.creds.simpleCreds.bindPw = argv[3];                           
  43.     con.ssl = NULL;                                                   
  44.     /* Connect to system configuration */                             
  45.     if (0!= (rc = eimConnect (&handle,                                
  46.                                con,                                   
  47.                                err)))                                 
  48.     {                                                                 
  49.        message = eimErr2String(err);                                  
  50.        sprintf(argv[4], "EIM API Connect Error Message: %s", message);
  51.        free(message);                                                 
  52.                                                                       
  53.        /*replace the NULL terminator with a space */                  
  54.        argv[4] [strlen(argv[4])] = ' ';                               
  55.        return -1;                                                     
  56.     }                                                                 
  57.                                                                       
  58.     /* Erase identifier */                                            
  59.     x.idtype = EIM_UNIQUE_NAME;                                       
  60.     x.id.uniqueName = argv[1];                                        
  61.                                                                       
  62.     /* delete identifier */ 
  63.     if (0 != (rc = eimRemoveIdentifier (&handle,                     
  64.                                         &x,                          
  65.                                         err)))                       
  66.     {                                                                
  67.        message = eimErr2String(err);                                 
  68.        sprintf(argv[4], "EIM API Remove Error Message: %s", message);
  69.        free(message);                                                
  70.     }                                                                
  71.                                                                      
  72.     /* destroy handle */                                             
  73.     rc = eimDestroyHandle (&handle, err);                            
  74.     message = eimErr2String(err);                                    
  75.     sprintf(argv[4], "EIM API Message: %s", message);                
  76.     argv[4] [strlen(argv[4])] = ' ';                                 
  77.     free(message);                                                   
  78.     return 0;                                                        
  79.  }                                                                   
© 2004-2019 by midrange.com generated in 0.061s valid xhtml & css