[Samba] Authenticating with Active Directory
Jociel Andrade
jcainfo at gmail.com
Tue Mar 13 15:05:08 GMT 2007
Hi all,
I need to authenticate Active Directory users in Solaris. I wrote a program
to do it using smbclient.a lib, but the method Valid_User is returning aways
the code 1 (Network Error). The program is in attachment.
When I use the following code, the user is sucessfully authenticated:
smbclient '\\192.168.0.20\downloads' -W adteste -U dmadmin%Senha123
But, this command log in the machine. I need a program that returns TRUE for
valid username/password and FALSE, otherwise. Can somebody help me?
Thanks in advance,
Jociel
-------------- next part --------------
#include "valid.h"
#include <stdarg.h>
#include <shadow.h>
#include <crypt.h>
#include <stdlib.h>
#include <sys/utsname.h>
#include <utmpx.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
void catch_sigpipe(int sig_num)
{
/* We were not able to read off of the domain authentication pipe. */
fputs("Signal error while authenticating domain.\n", stdout);
exit(0);
}
int main(int argc, char **argv) {
printf("userName:userPassword\n");
printf("%s:%s\n", argv[1], argv[2]);
void (*old_signal_handler)(int);
old_signal_handler = signal(SIGPIPE, catch_sigpipe);
//result = Valid_User(userName, userPassword, pdc, bdc, domain);
int result = Valid_User(argv[1], argv[2],
"192.168.0.20",
"192.168.0.20",
"ADTESTE");
signal(SIGPIPE, old_signal_handler);
printf("Resut: %d.\n", result);
switch (result)
{
case 0:
fputs("SMB Authentication Succeeded.\n", stdout);
break;
case 1:
fputs("SMB Network Error.\n", stdout);
break;
case 2:
fputs("SMB Protocol Error.\n", stdout);
break;
case 3:
fputs("Logon Error.\n", stdout);
break;
default:
fputs("Unknown Error.\n", stdout);
break;
}
return 0;
}
More information about the samba
mailing list