Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock account status of 103???

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
I am having trouble progammically loging into an account.
I get an account status of 103. This is on UNIX but I assume that the same error code is returned regardless of the system. Any help or does anyone know where I can get more information on this type of coding???

The code is

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>

#define SIZE sizeof(struct sockaddr_in)

typedef struct
{
int ui32RequestType;
char padding_1[28];
char achUserName[32];
char achPassword[32];
char achNewPassword[32];
char achDomain[32];
} AuthenticationRequest;

typedef struct
{
unsigned int ui32AccountStatus;
char padding_1[28];
unsigned int ui32MinPasswordLength;
char padding_2[28];
unsigned int ui32MaxPasswdAge;
char padding_3[28];
unsigned int ui32ExpirationDays;
char padding_4[28];
} AuthenticationResponse;

main(int argc, char *argv[])
{
int sockfd;
in_port_t port;
int bytesSent=0;
int totalBytesSent=0;
int bytesReceived=0;
int totalBytesReceived=0;

struct sockaddr_in server;
AuthenticationRequest hRequest;
AuthenticationResponse hResponse;

if (argc < 5)
{
printf(&quot;Invalid number of Arguments passed\n&quot;);
printf(&quot;prompt>chkcon UserID Password Domain IP\n&quot;);
exit(-1);
}

port = 12000;

printf(&quot;\nPreparing to validate connection using...\n&quot;);
printf(&quot;...User ID %s\n&quot;,argv[1]);
printf(&quot;...Password %s\n&quot;,argv[2]);
printf(&quot;...Domain %s\n&quot;,argv[3]);
printf(&quot;...Host %s\n&quot;,argv[4]);
printf(&quot;...Port %d\n\n&quot;,port);

printf(&quot;Getting socket...\n&quot;);
if ((sockfd = socket(PF_INET, SOCK_STREAM,0)) == -1)
{
printf(&quot;socket call failed:\n&quot;);
printf(&quot;...Error: %d->%s\n&quot;,errno,strerror(errno));
exit(1);
}

server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr(argv[4]);
server.sin_port = htons( port );

printf(&quot;Attempting to connect...\n&quot;);
if (connect(sockfd,(struct sockaddr *)&server, SIZE) == -1)
{
printf(&quot;...connect call failed:\n&quot;);
printf(&quot;...Error: %d->%s\n&quot;,errno,strerror(errno));
printf(&quot;Closing connection...\n&quot;);
close(sockfd);
exit(1);
}
else
printf(&quot;Connected to Server %s...\n&quot;,argv[4]);

memset( &hRequest, 0x00, sizeof( AuthenticationRequest ) );
memcpy( hRequest.achUserName, argv[1], strlen(argv[1]) );
memcpy( hRequest.achPassword, argv[2], strlen(argv[2]) );
memcpy( hRequest.achDomain, argv[3], strlen(argv[3]) );
hRequest.ui32RequestType = 0;

printf(&quot;Attempting to Authenticate...\n&quot;);
printf(&quot;...Sending request to server\n&quot;);
while( totalBytesSent < sizeof(AuthenticationRequest))
{

bytesSent = send(sockfd,&hRequest,sizeof(AuthenticationRequest),0);
switch(bytesSent)
{
case 0:
printf(&quot;...send call failed:\n&quot;);
printf(&quot;...Error: No data sent to Server\n&quot;);
printf(&quot;...Closing connection...\n&quot;);
close(sockfd);
exit(1);
case -1:
printf(&quot;...send call failed:\n&quot;);
printf(&quot;...Error: %d->%s\n&quot;,errno,strerror(errno));
printf(&quot;...Closing connection...\n&quot;);
close(sockfd);
exit(1);
default:
totalBytesSent += bytesSent;
}
}
printf(&quot;...Message sent\n&quot;);

printf(&quot;...Retreiving response from the server\n&quot;);
memset( &hResponse, 0x00, sizeof( AuthenticationResponse ) );
while( totalBytesReceived < sizeof(AuthenticationResponse))
{

bytesReceived = recv(sockfd,&hResponse,sizeof(AuthenticationResponse),0);
printf(&quot;...bytesReceived=%d\n&quot;,bytesReceived);
switch(bytesReceived)
{
case 0:
printf(&quot;...recv call failed:\n&quot;);
printf(&quot;...Error: No data received from Server\n&quot;);
printf(&quot;...Closing connection...\n&quot;);
close(sockfd);
exit(1);
case -1:
printf(&quot;...recv call failed:\n&quot;);
printf(&quot;...Error: %d->%s\n&quot;,errno,strerror(errno));
printf(&quot;...Closing connection...\n&quot;);
close(sockfd);
exit(1);
default:
totalBytesReceived += bytesReceived;
}
}

printf(&quot;Authentication was successful...\n&quot;);
printf(&quot;...Bytes Sent were %d\n&quot;, totalBytesSent);
printf(&quot;...Bytes Received were %d\n&quot;, totalBytesReceived);
printf(&quot;Closing connection...\n&quot;);
close(sockfd);

printf(&quot;Account Status: %d\n&quot;,ntohl(hResponse.ui32AccountStatus));
printf(&quot;Password attributes:\n&quot;);
printf(&quot;...Minimum length: %d\n&quot;,ntohl(hResponse.ui32MinPasswordLength));
printf(&quot;...Maximum age: %d\n&quot;,ntohl(hResponse.ui32MaxPasswdAge));
printf(&quot;...Expiration Days: %d\n&quot;,ntohl(hResponse.ui32ExpirationDays));
 
If your Winsock calls are returning OK, then what you're getting is an application-level error, and since I'm not sure what authentication service you're calling, I can't really help. Try posting in one of the Unix forums.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top