valid.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
11 #include "smblib/smblib.h"
12 
13 #if HAVE_SYS_TYPES_H
14 #include <sys/types.h>
15 #endif
16 #if HAVE_UNISTD_H
17 #include <unistd.h>
18 #endif
19 #if HAVE_SYSLOG_H
20 #include <syslog.h>
21 #endif
22 
23 // BACKUP is unused
24 int
25 Valid_User(char *USERNAME, char *PASSWORD, const char *SERVER, char *, const char *DOMAIN)
26 {
27  const char *supportedDialects[] = {"PC NETWORK PROGRAM 1.0",
28  "MICROSOFT NETWORKS 1.03",
29  "MICROSOFT NETWORKS 3.0",
30  "LANMAN1.0",
31  "LM1.2X002",
32  "Samba",
33  "NT LM 0.12",
34  "NT LANMAN 1.0",
35  NULL
36  };
37  SMB_Handle_Type con;
38 
39  SMB_Init();
40  con = SMB_Connect_Server(nullptr, SERVER, DOMAIN);
41  if (con == NULL) {
42  return (NTV_SERVER_ERROR);
43  }
44  if (SMB_Negotiate(con, supportedDialects) < 0) { /* An error */
45  SMB_Discon(con, 0);
46  return (NTV_PROTOCOL_ERROR);
47  }
48  if (SMB_Logon_Server(con, USERNAME, PASSWORD, nullptr, 0) < 0) {
49  SMB_Discon(con, 0);
50  return (NTV_LOGON_ERROR);
51  }
52  SMB_Discon(con, 0);
53  return (NTV_NO_ERROR);
54 }
55 
int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle)
Definition: smblib.c:577
#define NULL
Definition: types.h:145
#define NTV_LOGON_ERROR
Definition: valid.h:16
#define NTV_NO_ERROR
Definition: valid.h:13
int Valid_User(char *USERNAME, char *PASSWORD, const char *SERVER, char *, const char *DOMAIN)
Definition: valid.cc:25
#define NTV_SERVER_ERROR
Definition: valid.h:14
int SMB_Init()
Definition: smblib.c:67
SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, const char *server, const char *NTdomain)
Definition: smblib.c:101
#define NTV_PROTOCOL_ERROR
Definition: valid.h:15
int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, char *PassWord, const char *NtDomain, int PreCrypted)
Definition: smblib.c:332
int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[])
Definition: smblib-util.c:239

 

Introduction

Documentation

Support

Miscellaneous