chiark / gitweb /
Fix C%d[%d] messages
[inn-innduct.git] / authprogs / smbval / valid.c
1 #include <sys/types.h>
2 #include <unistd.h>
3 #include <syslog.h>
4 #include "config.h"
5 #include "smblib-priv.h"
6 #include "smblib.h"
7 #include "valid.h"
8
9 int Valid_User(char *USERNAME,char *PASSWORD,char *SERVER,char *BACKUP, char *DOMAIN)
10 {
11   char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
12                             "MICROSOFT NETWORKS 1.03",
13                             "MICROSOFT NETWORKS 3.0",
14                             "LANMAN1.0",
15                             "LM1.2X002",
16                             "Samba",
17                             "NT LM 0.12",
18                             "NT LANMAN 1.0",
19                             NULL};
20   SMB_Handle_Type con;
21
22   SMB_Init();
23   con = SMB_Connect_Server(NULL, SERVER, DOMAIN);
24   if (con == NULL) { /* Error ... */
25    con = SMB_Connect_Server(NULL, BACKUP, DOMAIN);
26    if (con == NULL) {
27         return(NTV_SERVER_ERROR);   
28    }
29   }
30   if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */
31     SMB_Discon(con,0);
32     return(NTV_PROTOCOL_ERROR);
33   }
34   /* Test for a server in share level mode do not authenticate against it */
35   if (con -> Security == 0)
36     {
37       SMB_Discon(con,0);
38       return(NTV_PROTOCOL_ERROR);
39     }
40
41   if (SMB_Logon_Server(con, USERNAME, PASSWORD) < 0) {
42     SMB_Discon(con,0);
43     return(NTV_LOGON_ERROR);
44   }
45   
46   SMB_Discon(con,0);
47   return(NTV_NO_ERROR);
48 }