User's Manual

invalid message digest 0 (0)
Packets received from unknown clients : 0 (0)
Packets received with unknown request : 0 (0)
Requests Received/Success/Failed : 5/3/2 (0/0/0)
Sample Code
This section lists a sample code that will help you get started in using the ArubaOS XML API interface. These
codes have been tested in a controlled environment. We recommend that you test this code in a non-
production environment before using it for actual user management tasks.
Using XML API in C Language
The example script is written in the C language. The example script (auth.c) sends an authentication request
from your authentication server to the controller.
This is an example code and is provided for illustration purposes. If you plan to use this code in your environment,
ensure that the code meets your IT guidelines. Also create an error free executable to successfully execute the
script.
Figure 243 Authentication Script Listing
##### auth.c listing
##### Authentication Script Example -- Start --
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <getopt.h>
char *command, *ipaddr, *macaddr;
char *name, *password, *role;
char *tout, *secret;
char *auth, *key, enchashbuf[41];
unsigned char hashbuf[20];
char *version;
char post[4096], cmdbuf[512], encbuf[1024];
#define DEBUG
#ifdef DEBUG
#define debug(x...) fprintf(stderr, x)
#else
#define debug(x...)
#endif
extern int cgi_escape_url(char *t, int tl, char *s, int sl, int b_newline);
static void encode_message_digest (unsigned char *md, int mdlen, char *output);
static void usage (void)
{
fprintf(stderr, "Usage: ecp [options] <switch> <command> [<secret>]\n");
fprintf(stderr, " \n");
fprintf(stderr, " <switch> Switch IP address.\n");
fprintf(stderr, " <command> One of add, del, or authenticate.\n");
fprintf(stderr, " <secret> Shared secret.\n");
fprintf(stderr, " \n");
fprintf(stderr, " -i ipaddr User IP address in A.B.C.D format.\n");
Dell Networking W-Series ArubaOS 6.4.x | User Guide External User Management | 1029