Example of creating and removing users.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
int AAP_API ListUsersCallback(
char *szUserName,
void * pParam,
BOOL bFinal)
{
UNUSED(pParam);
if (!bFinal)
printf("\t%s\n", szUserName);
return 0;
}
int main()
{
int nRet = 0;
char szUser[] = "UsuarioTeste";
if (nRet){
printf("Falha na funcao: DInitialize \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Bibliotecas inicializadas.\n");
strncpy(authPwd.szAddr, HOST_ADDR, sizeof(authPwd.szAddr));
strncpy(authPwd.szUserId, USER_ID, sizeof(authPwd.szUserId));
strncpy(authPwd.szPassword, USER_PWD, sizeof(authPwd.szPassword));
sizeof(authPwd),
if (nRet){
printf("Falha na funcao: DOpenSession \nCodigo de erro: %d\n",nRet);
goto clean;
}
strncpy(userInfo.szUserId, szUser, sizeof(userInfo.szUserId));
strncpy(userInfo.szPassword, "12345678", sizeof(userInfo.szPassword));
if (nRet){
printf("Falha na funcao: DCreateUser \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Lista de usuarios:\n");
nRet =
DListUsers(hSession, ListUsersCallback, NULL);
if (nRet){
printf("Falha na funcao: DListUsers \nCodigo de erro: %d\n",nRet);
goto clean;
}
if (nRet){
printf("Falha na funcao: DRemoveUser \nCodigo de erro: %d\n",nRet);
goto clean;
}
clean:
if (hSession){
printf("Sessao encerrada.\n");
}
printf("Bibliotecas finalizada.\n");
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
int BOOL
Definição dinamo.h:49
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1934
unsigned char BYTE
Definição dinamo.h:45
#define ACL_OBJ_UPDATE
Definição dinamo.h:1529
#define AAP_API
Definição dinamo.h:42
#define ENCRYPTED_CONN
Definição dinamo.h:570
#define SS_USER_PWD
Definição dinamo.h:561
#define ACL_OBJ_CREATE
Definição dinamo.h:1528
#define ACL_OBJ_DEL
Definição dinamo.h:1525
#define ACL_OBJ_READ
Definição dinamo.h:1526
int AAP_API DOpenSession(HSESSIONCTX *phSession, DWORD dwParam, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
int AAP_API DCloseSession(HSESSIONCTX *phSession, DWORD dwFlags)
int AAP_API DInitialize(DWORD dwReserved)
int AAP_API DRemoveUser(HSESSIONCTX hSession, char *szUserId)
int AAP_API DCreateUser(HSESSIONCTX hSession, struct USER_INFO userInfo)
int AAP_API DListUsers(HSESSIONCTX hSession, funcListUsersCallback fncallback, void *pParam)