- User's authentication method now can be configured from console
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 13 Jun 2006 21:39:17 +0000 (21:39 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 13 Jun 2006 21:39:17 +0000 (21:39 +0000)
- Database schema updated (GUIDs)
- Database upgrade to V41 implemented
- Some minor fixes

25 files changed:
doc/internal/db_format_change.txt
include/nms_cscp.h
include/nxclapi.h
include/uuid.h
sql/schema.in
sql/setup.in
src/console/win32/UserEditor.cpp
src/console/win32/UserPropDlg.cpp
src/console/win32/UserPropDlg.h
src/console/win32/globals.cpp
src/console/win32/globals.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/libnetxms/gen_uuid.c
src/libnetxms/uuid.c
src/libnxcl/users.cpp
src/server/core/session.cpp
src/server/core/users.cpp
src/server/include/nxsrvapi.h
src/server/libnxsrv/db.cpp
src/server/libnxsrv/libnxsrv.h
src/server/tools/nxdbmgr/check.cpp
src/server/tools/nxdbmgr/nxdbmgr.h
src/server/tools/nxdbmgr/upgrade.cpp

index ded7a46..280516c 100644 (file)
@@ -5,11 +5,11 @@
 - New configuration parameters: RADIUSServer, RADIUSSecret, RADIUSPort,
   RADIUSNumRetries, RADIUSTimeout
 - Added column "guid" to table "users":
-       ALTER TABLE users ADD guid varchar(32) not null;
+       ALTER TABLE users ADD guid varchar(36) not null;
 - Added column "auth_method" to table "users":
        ALTER TABLE users ADD auth_method integer not null;
 - Added column "guid" to table "user_groups":
-       ALTER TABLE user_groups ADD guid varchar(32) not null;
+       ALTER TABLE user_groups ADD guid varchar(36) not null;
 
 
 *************
index 33a717b..530f25b 100644 (file)
@@ -635,6 +635,7 @@ typedef struct
 #define VID_DST_USER_ID             ((DWORD)219)
 #define VID_MOVE_FLAG               ((DWORD)220)
 #define VID_CHANGE_PASSWD_FLAG      ((DWORD)221)
+#define VID_GUID                    ((DWORD)222)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
index c6d525e..a901e13 100644 (file)
@@ -31,6 +31,7 @@
 #include <nxcscpapi.h>
 #include <nxtools.h>
 #include <nxlog.h>
+#include <uuid.h>
 
 #ifdef _WIN32
 #ifdef LIBNXCL_EXPORTS
@@ -886,9 +887,11 @@ typedef struct
 typedef struct
 {
    TCHAR szName[MAX_USER_NAME];
+   uuid_t guid;
    DWORD dwId;
    WORD wFlags;
    WORD wSystemRights;
+   int nAuthMethod;        // Only for users
    DWORD dwNumMembers;     // Only for groups
    DWORD *pdwMemberList;   // Only for groups
    TCHAR szFullName[MAX_USER_FULLNAME];    // Only for users
index 8f613b7..ef81848 100644 (file)
 #ifndef _UUID_H_
 #define _UUID_H_
 
+#define UUID_LENGTH     16
+
 #undef uuid_t
 typedef unsigned char uuid_t[16];
 
 /* UUID Variant definitions */
-#define UUID_VARIANT_NCS       0
-#define UUID_VARIANT_DCE       1
-#define UUID_VARIANT_MICROSOFT 2
-#define UUID_VARIANT_OTHER     3
+#define UUID_VARIANT_NCS         0
+#define UUID_VARIANT_DCE         1
+#define UUID_VARIANT_MICROSOFT   2
+#define UUID_VARIANT_OTHER       3
 
 #ifdef __cplusplus
 extern "C" {
@@ -30,14 +32,11 @@ int LIBNETXMS_EXPORTABLE uuid_compare(uuid_t uu1, uuid_t uu2);
 void LIBNETXMS_EXPORTABLE uuid_copy(uuid_t uu1, uuid_t uu2);
 void LIBNETXMS_EXPORTABLE uuid_generate(uuid_t out);
 int LIBNETXMS_EXPORTABLE uuid_is_null(uuid_t uu);
+int LIBNETXMS_EXPORTABLE uuid_parse(char *in, uuid_t uu);
+char LIBNETXMS_EXPORTABLE *uuid_to_string(uuid_t uu, char *out);
 
 #ifdef __cplusplus
 }
 #endif
 
-/*
-int uuid_parse(char *in, uuid_t uu);
-void uuid_unparse(uuid_t uu, char *out);
-*/
-
 #endif
index 05886d4..ea8531b 100644 (file)
@@ -45,7 +45,7 @@ CREATE TABLE modules
 CREATE TABLE users
 (
        id integer not null,
-       guid varchar(32) not null,
+       guid varchar(36) not null,
        name varchar(63) not null,
        password varchar(48) not null,
        system_access integer not null,
@@ -65,7 +65,7 @@ CREATE TABLE users
 CREATE TABLE user_groups
 (
        id integer not null,
-       guid varchar(32) not null,
+       guid varchar(36) not null,
        name varchar(63) not null,
        system_access integer not null,
        flags integer not null,
index be8e7b4..3f4e82a 100644 (file)
@@ -142,6 +142,7 @@ INSERT INTO config (var_name,var_value,is_visible,need_server_restart)
 ** Default users
 */
 
+/*
 INSERT INTO users (id,name,password,system_access,flags,full_name,description,grace_logins)
    VALUES (0,'admin',
            '3A445C0072CD69D9030CC6644020E5C4576051B1', // Default password: netxms
@@ -151,14 +152,15 @@ INSERT INTO users (id,name,password,system_access,flags,full_name,description,gr
    VALUES (1,'guest','DA39A3EE5E6B4B0D3255BFEF95601890AFD80709', // Default password is empty
            0,0,'','Default guest user',5
           );
+*/
 
 
 /*
 ** Special "Everyone" user group
 */
 
-INSERT INTO user_groups (id,name,system_access,flags,description)
-   VALUES (-2147483648, 'Everyone', 16, 0, 'Built-in everyone group');
+INSERT INTO user_groups (id,name,system_access,flags,description,guid)
+   VALUES (-2147483648, 'Everyone', 16, 0, 'Built-in everyone group','00000000-0000-0000-0000-000000000000');
 
 
 /*
index 2c6967a..630cf6a 100644 (file)
@@ -397,6 +397,7 @@ void CUserEditor::OnUserProperties()
             dlg.m_strLogin = pUser->szName;
             dlg.m_strFullName = pUser->szFullName;
             dlg.m_strDescription = pUser->szDescription;
+            dlg.m_nAuthMethod = pUser->nAuthMethod;
             dlg.m_bAccountDisabled = (pUser->wFlags & UF_DISABLED) ? TRUE : FALSE;
             dlg.m_bChangePassword = (pUser->wFlags & UF_CHANGE_PASSWORD) ? TRUE : FALSE;
             dlg.m_bDropConn = (pUser->wSystemRights & SYSTEM_ACCESS_MANAGE_SESSIONS) ? TRUE : FALSE;
@@ -415,6 +416,7 @@ void CUserEditor::OnUserProperties()
                strcpy(userInfo.szName, (LPCTSTR)dlg.m_strLogin);
                strcpy(userInfo.szFullName, (LPCTSTR)dlg.m_strFullName);
                strcpy(userInfo.szDescription, (LPCTSTR)dlg.m_strDescription);
+               userInfo.nAuthMethod = dlg.m_nAuthMethod;
                userInfo.wFlags = (dlg.m_bAccountDisabled ? UF_DISABLED : 0) |
                                  (dlg.m_bChangePassword ? UF_CHANGE_PASSWORD : 0);
                userInfo.wSystemRights = (dlg.m_bDropConn ? SYSTEM_ACCESS_MANAGE_SESSIONS : 0) |
index e794e58..f702174 100644 (file)
@@ -35,6 +35,7 @@ CUserPropDlg::CUserPropDlg(CWnd* pParent /*=NULL*/)
        m_bDeleteAlarms = FALSE;
        m_bManagePkg = FALSE;
        //}}AFX_DATA_INIT
+   m_nAuthMethod = 0;
 }
 
 
@@ -42,6 +43,7 @@ void CUserPropDlg::DoDataExchange(CDataExchange* pDX)
 {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CUserPropDlg)
+       DDX_Control(pDX, IDC_COMBO_AUTH, m_wndComboAuth);
        DDX_Check(pDX, IDC_CHECK_DISABLED, m_bAccountDisabled);
        DDX_Check(pDX, IDC_CHECK_DROP_CONN, m_bDropConn);
        DDX_Check(pDX, IDC_CHECK_EDIT_EVENTDB, m_bEditEventDB);
@@ -74,21 +76,52 @@ END_MESSAGE_MAP()
 
 BOOL CUserPropDlg::OnInitDialog() 
 {
+   int i;
+
        CDialog::OnInitDialog();
 
    if (m_pUser->dwId == 0)
    {
       // Disable checkboxes with system access rights for superuser
-      GetDlgItem(IDC_CHECK_DISABLED)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_DROP_CONN)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_MANAGE_USERS)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_SNMP_TRAPS)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_MANAGE_CONFIG)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_VIEW_EVENTDB)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_EDIT_EVENTDB)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_MANAGE_ACTIONS)->EnableWindow(FALSE);
-      GetDlgItem(IDC_CHECK_MANAGE_EPP)->EnableWindow(FALSE);
+      EnableDlgItem(this, IDC_CHECK_DISABLED, FALSE);
+      EnableDlgItem(this, IDC_CHECK_DROP_CONN, FALSE);
+      EnableDlgItem(this, IDC_CHECK_MANAGE_USERS, FALSE);
+      EnableDlgItem(this, IDC_CHECK_SNMP_TRAPS, FALSE);
+      EnableDlgItem(this, IDC_CHECK_MANAGE_CONFIG, FALSE);
+      EnableDlgItem(this, IDC_CHECK_VIEW_EVENTDB, FALSE);
+      EnableDlgItem(this, IDC_CHECK_EDIT_EVENTDB, FALSE);
+      EnableDlgItem(this, IDC_CHECK_MANAGE_ACTIONS, FALSE);
+      EnableDlgItem(this, IDC_CHECK_MANAGE_EPP, FALSE);
+      EnableDlgItem(this, IDC_CHECK_MANAGE_PKG, FALSE);
+      EnableDlgItem(this, IDC_CHECK_DELETE_ALARMS, FALSE);
    }
 
+   for(i = 0; g_szAuthMethod[i] != NULL; i++)
+      m_wndComboAuth.AddString(g_szAuthMethod[i]);
+   if ((m_nAuthMethod < 0) || (m_nAuthMethod >= i))
+      m_nAuthMethod = 0;
+   m_wndComboAuth.SelectString(-1, g_szAuthMethod[m_nAuthMethod]);
+
        return TRUE;
 }
+
+
+//
+// OK button handler
+//
+
+void CUserPropDlg::OnOK() 
+{
+   int i;
+   TCHAR szText[256];
+
+   m_wndComboAuth.GetWindowText(szText, 256);
+   for(i = 0; g_szAuthMethod[i] != NULL; i++)
+      if (!_tcscmp(szText, g_szAuthMethod[i]))
+      {
+         m_nAuthMethod = i;
+         break;
+      }
+
+       CDialog::OnOK();
+}
index 426c89d..f47f63e 100644 (file)
@@ -14,12 +14,14 @@ class CUserPropDlg : public CDialog
 {
 // Construction
 public:
+       int m_nAuthMethod;
        NXC_USER * m_pUser;
        CUserPropDlg(CWnd* pParent = NULL);   // standard constructor
 
 // Dialog Data
        //{{AFX_DATA(CUserPropDlg)
        enum { IDD = IDD_USER_PROPERTIES };
+       CComboBox       m_wndComboAuth;
        BOOL    m_bAccountDisabled;
        BOOL    m_bDropConn;
        BOOL    m_bEditEventDB;
@@ -51,6 +53,7 @@ protected:
        // Generated message map functions
        //{{AFX_MSG(CUserPropDlg)
        virtual BOOL OnInitDialog();
+       virtual void OnOK();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index a4ff671..2655e7c 100644 (file)
@@ -171,6 +171,7 @@ TCHAR *g_szInterfaceTypes[] =
    "SMDS",
    "Frame Relay"
 };
+TCHAR *g_szAuthMethod[] = { _T("NetXMS Password"), _T("RADIUS"), _T("RSA SecureID"), NULL };
 
 
 //
index 7ea86be..8492f64 100644 (file)
@@ -349,6 +349,7 @@ extern TCHAR *g_szToolType[];
 extern TCHAR *g_szToolColFmt[];
 extern TCHAR *g_szSyslogSeverity[];
 extern TCHAR *g_szSyslogFacility[];
+extern TCHAR *g_szAuthMethod[];
 extern COLORREF g_statusColorTable[];
 extern char *g_szObjectClass[];
 extern char *g_szInterfaceTypes[];
index 92a1339..d4da421 100644 (file)
@@ -2,7 +2,7 @@
 
 [General Info]
 Version=1
-LastClass=CPasswordChangeDlg
+LastClass=CUserPropDlg
 LastTemplate=CMDIChildWnd
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
@@ -17,20 +17,20 @@ Class9=CMapView
 
 ResourceCount=173
 Resource1=IDD_CP_GENERAL (English (U.S.))
-Resource2=IDD_OBJECT_RELATIONS
+Resource2=IDD_SELECT_OBJECT
 Resource3=IDD_DCI_DATA_EXPORT (English (U.S.))
-Resource4=IDD_OBJTOOL_GENERAL
-Resource5=IDA_MDI_DEFAULT
+Resource4=IDD_OBJTOOL_OPTIONS
+Resource5=IDA_EPP
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_CP_GENERAL
+Resource6=IDD_ACTION_PROPERTIES
 Class11=CProgressDialog
-Resource7=IDD_DCI_DATA_EXPORT
+Resource7=IDD_CREATE_VPNC
 Class12=CObjectBrowser
-Resource8=IDD_SELECT_AGENT_PARAM
+Resource8=IDD_CREATE_NETSRV
 Class13=CObjectPropDlg
 Resource9=IDD_THRESHOLD (English (U.S.))
 Resource10=IDD_SELECT_OBJECT (English (U.S.))
@@ -46,7 +46,7 @@ Resource17=IDD_NEW_USER (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDD_NEW_ACTION (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_OBJTOOL_OPTIONS
+Resource20=IDD_OBJECT_GENERAL
 Class17=CObjectPreview
 Resource21=IDA_OBJECT_BROWSER (English (U.S.))
 Class18=CToolBox
@@ -59,32 +59,32 @@ Class23=CNodePropsGeneral
 Resource23=IDD_GRAPH_PROPERTIES (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDD_EDIT_RULE_ALARM
+Resource24=IDA_DC_EDITOR
 Class26=CRequestProcessingDlg
 Resource25=IDD_SELECT_USER (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_OBJTOOL_COLUMNS (English (U.K.))
+Resource27=IDD_SUBMAP_BKGND
 Resource28=IDD_DCI_COLLECTION (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDR_MAINFRAME (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDD_SAVE_AGENT_CFG (English (U.S.))
-Resource31=IDD_LASTVAL_PROP
-Resource32=IDD_GRAPH_PROP_DATA
+Resource31=IDD_EDIT_VARIABLE
+Resource32=IDD_OBJECT_PRESENTATION
 Class29=CUserSelectDlg
-Resource33=IDD_SAVE_AGENT_CFG
+Resource33=IDD_OBJECT_STATUS
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDD_DATA_QUERY
-Resource36=IDD_NEW_ACTION
+Resource35=IDD_EDIT_TRAP_ARG
+Resource36=IDD_SELECT_ACTION
 Class32=CUserPropDlg
 Resource37=IDD_EDIT_VARIABLE (English (U.S.))
-Resource38=IDA_NETMAP
+Resource38=IDD_GRAPH_PROP_SETTINGS
 Class33=CGroupPropDlg
 Resource39=IDM_VIEW_SPECIFIC
-Resource40=IDD_CHANGE_IP
-Resource41=IDD_DCI_SCHEDULE
+Resource40=IDD_EDIT_TRAP
+Resource41=IDD_OBJTOOL_GENERAL
 Resource42=IDA_ACTION_EDITOR (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -100,55 +100,55 @@ Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
 Resource47=IDM_CONTEXT (English (U.S.))
-Resource48=IDD_SELECT_ACTION
+Resource48=IDD_CREATE_NODE
 Class43=CThresholdDlg
 Resource49=IDD_DESKTOP_SAVE_AS (English (U.S.))
-Resource50=IDA_GRAPH
+Resource50=IDA_LAST_VALUES
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDD_SELECT_AGENT_PARAM (English (U.S.))
-Resource52=IDA_EPP
+Resource52=IDA_NETMAP
 Class48=CObjectSelDlg
-Resource53=IDD_SELECT_INTERNAL_ITEM
-Resource54=IDD_DCI_TRANSFORM
+Resource53=IDD_INPUT_BOX
+Resource54=IDD_REQUEST_PROCESSING
 Class49=CRuleCommentDlg
-Resource55=IDD_EDIT_IP_SUBNET
+Resource55=IDA_SCRIPT_MANAGER
 Class50=CEventSelDlg
-Resource56=IDA_ACTION_EDITOR
+Resource56=IDA_GRAPH
 Resource57=IDA_EPP (English (U.S.))
-Resource58=IDD_OBJECT_NETSRV_GENERAL
+Resource58=IDD_OBJECT_RELATIONS
 Resource59=IDA_PACKAGE_MGR (English (U.S.))
 Resource60=IDD_OBJTOOL_GENERAL (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_CREATE_TEMPLATE (English (U.S.))
-Resource62=IDD_NEW_OBJECT_TOOL
+Resource62=IDD_CHANGE_IP
 Class52=CRuleSeverityDlg
-Resource63=IDR_MAINFRAME
+Resource63=IDD_DCI_COLLECTION
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
 Resource64=IDA_MDI_DEFAULT (English (U.S.))
-Resource65=IDA_ALARM_BROWSER
+Resource65=IDA_EVENT_EDITOR
 Resource66=IDD_EDIT_IP_SUBNET (English (U.S.))
 Resource67=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Resource68=IDD_ACTION_PROPERTIES (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDD_CREATE_NODE
-Resource70=IDD_SUBMAP_BKGND
+Resource69=IDD_CREATE_TG
+Resource70=IDA_MDI_DEFAULT
 Class57=CNewActionDlg
-Resource71=IDD_CREATE_TEMPLATE
+Resource71=IDD_OBJTOOL_COLUMNS (English (U.K.))
 Class58=CEditActionDlg
 Resource72=IDM_CONTEXT
 Class59=CActionSelDlg
-Resource73=IDD_OBJECT_CAPS
+Resource73=IDD_REMOVE_TEMPLATE (English (U.K.))
 Resource74=IDD_EDIT_TRAP (English (U.S.))
 Resource75=IDD_USER_PROPERTIES (English (U.S.))
-Resource76=IDD_EDIT_VARIABLE
+Resource76=IDA_AGENT_CFG_EDITOR
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
-Resource77=IDD_EDIT_RULE_SEVERITY
+Resource77=IDD_CP_GENERAL
 Class62=CCreateNodeDlg
 Resource78=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Resource79=IDT_MAP (English (U.S.))
@@ -158,27 +158,27 @@ Resource81=IDD_LASTVAL_PROP (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
-Resource83=IDA_TRAP_EDITOR
-Resource84=IDD_CREATE_TG
+Resource83=IDD_DCI_DATA_EXPORT
+Resource84=IDD_DATA_QUERY
 Class66=CCreateTemplateDlg
 Class67=CCreateTGDlg
-Resource85=IDD_GRAPH_PROP_SETTINGS
-Resource86=IDD_DESKTOP_SAVE_AS
+Resource85=IDD_LASTVAL_PROP
+Resource86=IDD_GRAPH_PROP_DATA
 Class68=CTrapEditor
-Resource87=IDD_CREATE_CONTAINER
-Resource88=IDD_OBJECT_VPNC_GENERAL
-Resource89=IDD_ACTION_PROPERTIES
+Resource87=IDD_DCI_TRANSFORM
+Resource88=IDD_SAVE_AGENT_CFG
+Resource89=IDD_ABOUTBOX
 Class69=CDataQueryDlg
-Resource90=IDD_REMOVE_TEMPLATE (English (U.K.))
+Resource90=IDD_SNMP_WALK (English (U.K.))
 Class70=CTrapEditDlg
 Resource91=IDM_VIEW_SPECIFIC (English (U.S.))
 Class71=CTrapParamDlg
-Resource92=IDD_OBJECT_NODE_POLL
-Resource93=IDA_EVENT_EDITOR
+Resource92=IDD_DESKTOP_SAVE_AS
+Resource93=IDD_EDIT_RULE_COMMENT
 Class72=CGraphPropDlg
 Class73=CColorSelector
 Class74=CPackageMgr
-Resource94=IDD_CREATE_VPNC
+Resource94=IDD_NEW_ACTION
 Resource95=IDA_SCRIPT_MANAGER (English (U.S.))
 Resource96=IDD_SET_PASSWORD (English (U.S.))
 Resource97=IDD_DCI_TRANSFORM (English (U.S.))
@@ -270,41 +270,41 @@ Class119=CMapControlBox
 Resource138=IDD_OBJECT_GENERAL (English (U.S.))
 Class120=CSubmapBkgndDlg
 Resource139=IDD_SUBMAP_BKGND (English (U.S.))
-Resource140=IDD_SNMP_WALK (English (U.K.))
-Resource141=IDD_REQUEST_PROCESSING
-Resource142=IDD_EDIT_TRAP_ARG
-Resource143=IDA_OBJECT_BROWSER
-Resource144=IDD_INPUT_BOX
-Resource145=IDD_CREATE_NETSRV
-Resource146=IDA_PACKAGE_MGR
-Resource147=IDA_SERVER_CFG_EDITOR
-Resource148=IDA_AGENT_CFG_EDITOR
-Resource149=IDA_DC_EDITOR
-Resource150=IDA_OBJECT_TOOLS_EDITOR
-Resource151=IDA_SCRIPT_MANAGER
-Resource152=IDD_ABOUTBOX
-Resource153=IDD_EDIT_EVENT
-Resource154=IDD_OBJECT_NODE_GENERAL
-Resource155=IDD_OBJECT_STATUS
-Resource156=IDD_EDIT_TRAP
-Resource157=IDD_OBJECT_GENERAL
-Resource158=IDD_OBJECT_SECURITY
-Resource159=IDD_SELECT_USER
-Resource160=IDD_MIB_BROWSER
-Resource161=IDD_USER_PROPERTIES
-Resource162=IDD_GROUP_PROPERTIES
-Resource163=IDD_SET_PASSWORD
-Resource164=IDD_DCI_COLLECTION
-Resource165=IDD_DCI_THRESHOLDS
-Resource166=IDD_THRESHOLD
-Resource167=IDD_NEW_USER
-Resource168=IDD_SELECT_OBJECT
-Resource169=IDD_EDIT_RULE_COMMENT
-Resource170=IDD_SELECT_EVENT
-Resource171=IDD_OBJECT_PRESENTATION
+Resource140=IDR_MAINFRAME
+Resource141=IDD_OBJECT_SECURITY
+Resource142=IDD_SELECT_AGENT_PARAM
+Resource143=IDD_OBJECT_NODE_POLL
+Resource144=IDD_OBJECT_NETSRV_GENERAL
+Resource145=IDD_DCI_THRESHOLDS
+Resource146=IDA_SERVER_CFG_EDITOR
+Resource147=IDD_EDIT_IP_SUBNET
+Resource148=IDA_OBJECT_TOOLS_EDITOR
+Resource149=IDD_DCI_SCHEDULE
+Resource150=IDD_CREATE_CONTAINER
+Resource151=IDD_EDIT_EVENT
+Resource152=IDD_OBJECT_NODE_GENERAL
+Resource153=IDD_OBJECT_CAPS
+Resource154=IDD_CREATE_TEMPLATE
+Resource155=IDD_NEW_OBJECT_TOOL
+Resource156=IDD_SELECT_INTERNAL_ITEM
+Resource157=IDD_SELECT_USER
+Resource158=IDD_NEW_USER
+Resource159=IDD_USER_PROPERTIES
+Resource160=IDA_TRAP_EDITOR
+Resource161=IDA_OBJECT_BROWSER
+Resource162=IDD_SET_PASSWORD
+Resource163=IDA_ALARM_BROWSER
+Resource164=IDD_THRESHOLD
+Resource165=IDD_MIB_BROWSER
+Resource166=IDA_ACTION_EDITOR
+Resource167=IDD_GROUP_PROPERTIES
+Resource168=IDD_SELECT_EVENT
+Resource169=IDA_PACKAGE_MGR
+Resource170=IDD_EDIT_RULE_SEVERITY
+Resource171=IDD_EDIT_RULE_ALARM
 Class121=CModuleManager
 Class122=CDesktopManager
-Resource172=IDA_LAST_VALUES
+Resource172=IDD_OBJECT_VPNC_GENERAL
 Resource173=IDD_CHANGE_PASSWORD
 
 [CLS:CConsoleApp]
@@ -1480,7 +1480,7 @@ VirtualFilter=dWC
 [DLG:IDD_USER_PROPERTIES]
 Type=1
 Class=CUserPropDlg
-ControlCount=22
+ControlCount=25
 Control1=IDC_EDIT_LOGIN_NAME,edit,1350631552
 Control2=IDC_EDIT_NAME,edit,1350631552
 Control3=IDC_EDIT_DESCRIPTION,edit,1350631552
@@ -1496,13 +1496,16 @@ Control12=IDC_CHECK_VIEW_EVENTDB,button,1342242819
 Control13=IDC_CHECK_EDIT_EVENTDB,button,1342242819
 Control14=IDC_CHECK_MANAGE_ACTIONS,button,1342242819
 Control15=IDC_CHECK_DELETE_ALARMS,button,1342242819
-Control16=IDOK,button,1342242817
-Control17=IDCANCEL,button,1342242816
-Control18=IDC_STATIC,static,1342308352
+Control16=IDC_COMBO_AUTH,combobox,1344339971
+Control17=IDOK,button,1342242817
+Control18=IDCANCEL,button,1342242816
 Control19=IDC_STATIC,static,1342308352
 Control20=IDC_STATIC,static,1342308352
-Control21=IDC_STATIC,button,1342177287
+Control21=IDC_STATIC,static,1342308352
 Control22=IDC_STATIC,button,1342177287
+Control23=IDC_STATIC,button,1342177287
+Control24=IDC_STATIC,button,1342177287
+Control25=IDC_STATIC,static,1342308352
 
 [DLG:IDD_GROUP_PROPERTIES]
 Type=1
index c12e3c4..005311a 100644 (file)
@@ -1217,7 +1217,7 @@ BEGIN
     LTEXT           "Login name",IDC_STATIC_HEADER,7,7,113,8
 END
 
-IDD_USER_PROPERTIES DIALOG DISCARDABLE  0, 0, 222, 201
+IDD_USER_PROPERTIES DIALOG DISCARDABLE  0, 0, 222, 241
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "User Properties"
 FONT 8, "MS Sans Serif"
@@ -1250,13 +1250,17 @@ BEGIN
                     BS_AUTOCHECKBOX | WS_TABSTOP,119,150,86,10
     CONTROL         "Delete ala&rms",IDC_CHECK_DELETE_ALARMS,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,119,161,86,10
-    DEFPUSHBUTTON   "OK",IDOK,110,180,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,165,180,50,14
+    COMBOBOX        IDC_COMBO_AUTH,92,192,117,61,CBS_DROPDOWNLIST | 
+                    WS_VSCROLL | WS_TABSTOP
+    DEFPUSHBUTTON   "OK",IDOK,110,220,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,165,220,50,14
     LTEXT           "Login name:",IDC_STATIC,7,10,40,8
     LTEXT           "Full name:",IDC_STATIC,7,29,33,8
     LTEXT           "Description:",IDC_STATIC,7,48,38,8
     GROUPBOX        "Flags",IDC_STATIC,7,63,208,38
     GROUPBOX        "System Rights",IDC_STATIC,7,106,208,70
+    GROUPBOX        "Authentication",IDC_STATIC,7,181,208,31
+    LTEXT           "Authentication method:",IDC_STATIC,13,194,74,8
 END
 
 IDD_GROUP_PROPERTIES DIALOGEX 0, 0, 223, 266
@@ -2510,7 +2514,7 @@ BEGIN
         LEFTMARGIN, 7
         RIGHTMARGIN, 215
         TOPMARGIN, 7
-        BOTTOMMARGIN, 194
+        BOTTOMMARGIN, 234
     END
 
     IDD_GROUP_PROPERTIES, DIALOG
index ec848f6..bfb714f 100644 (file)
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        324
 #define _APS_NEXT_COMMAND_VALUE         33017
-#define _APS_NEXT_CONTROL_VALUE         1352
+#define _APS_NEXT_CONTROL_VALUE         1353
 #define _APS_NEXT_SYMED_VALUE           128
 #endif
 #endif
index 1cf9ba8..94272d7 100644 (file)
@@ -116,6 +116,7 @@ static void get_random_bytes(void *buf, int nbytes)
                return;
 
        /* XXX put something better here if no /dev/random! */
+   srand(time(NULL) ^ getpid());
        for (i=0; i < nbytes; i++)
                *cp++ = rand() & 0xFF;
        return;
@@ -193,7 +194,8 @@ static int get_node_id(unsigned char *node_id)
 #endif /* SIOCGIFHWADDR */
                if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
                        continue;
-               if (node_id) {
+               if (node_id)
+      {
                        memcpy(node_id, a, 6);
                        close(sd);
                        return 1;
@@ -216,8 +218,8 @@ static int get_clock(DWORD *clock_high, DWORD *clock_low, WORD *ret_clock_seq)
        QWORD clock_reg;
 #ifdef _WIN32
    FILETIME ft;
-   LARGE_INTEGER li;
-   __int64 t;
+   ULARGE_INTEGER li;
+   unsigned __int64 t;
 #endif
        
 try_again:
index efeee86..94821c2 100644 (file)
@@ -141,3 +141,63 @@ void uuid_unpack(uuid_t in, struct uuid *uu)
 
        memcpy(uu->node, ptr, 6);
 }
+
+
+//
+// Parse UUID
+//
+
+int LIBNETXMS_EXPORTABLE uuid_parse(char *in, uuid_t uu)
+{
+       struct uuid uuid;
+       int i;
+       char *cp, buf[3];
+
+       if (strlen(in) != 36)
+               return -1;
+       for (i=0, cp = in; i <= 36; i++,cp++) {
+               if ((i == 8) || (i == 13) || (i == 18) ||
+                   (i == 23))
+                       if (*cp == '-')
+                               continue;
+               if (i== 36)
+                       if (*cp == 0)
+                               continue;
+               if (!isxdigit((int) *cp))
+                       return -1;
+       }
+       uuid.time_low = strtoul(in, NULL, 16);
+       uuid.time_mid = (WORD)strtoul(in + 9, NULL, 16);
+       uuid.time_hi_and_version = (WORD)strtoul(in + 14, NULL, 16);
+       uuid.clock_seq = (WORD)strtoul(in + 19, NULL, 16);
+       cp = in + 24;
+       buf[2] = 0;
+       for(i = 0; i < 6; i++)
+   {
+               buf[0] = *cp++;
+               buf[1] = *cp++;
+               uuid.node[i] = (BYTE)strtoul(buf, NULL, 16);
+       }
+       
+       uuid_pack(&uuid, uu);
+       return 0;
+}
+
+
+//
+// Convert packed UUID to string
+//
+
+char LIBNETXMS_EXPORTABLE *uuid_to_string(uuid_t uu, char *out)
+{
+       struct uuid uuid;
+
+       uuid_unpack(uu, &uuid);
+       sprintf(out,
+               "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+               uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
+               uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
+               uuid.node[0], uuid.node[1], uuid.node[2],
+               uuid.node[3], uuid.node[4], uuid.node[5]);
+   return out;
+}
index 2c42dfa..e788546 100644 (file)
@@ -36,6 +36,7 @@ void UpdateUserFromMessage(CSCPMessage *pMsg, NXC_USER *pUser)
    pUser->wFlags = pMsg->GetVariableShort(VID_USER_FLAGS);
    pUser->wSystemRights = pMsg->GetVariableShort(VID_USER_SYS_RIGHTS);
    pMsg->GetVariableStr(VID_USER_DESCRIPTION, pUser->szDescription, MAX_USER_DESCR);
+   pMsg->GetVariableBinary(VID_GUID, pUser->guid, UUID_LENGTH);
 
    // Process group-specific fields
    if (pUser->dwId & GROUP_FLAG)
@@ -49,6 +50,7 @@ void UpdateUserFromMessage(CSCPMessage *pMsg, NXC_USER *pUser)
    }
    else     // User-specific data
    {
+      pUser->nAuthMethod = pMsg->GetVariableShort(VID_AUTH_METHOD);
       pMsg->GetVariableStr(VID_USER_FULL_NAME, pUser->szFullName, MAX_USER_FULLNAME);
       pUser->pdwMemberList = NULL;
    }
@@ -191,6 +193,7 @@ DWORD LIBNXCL_EXPORTABLE NXCModifyUser(NXC_SESSION hSession, NXC_USER *pUserInfo
    else     // User-specific fields
    {
       msg.SetVariable(VID_USER_FULL_NAME, pUserInfo->szFullName);
+      msg.SetVariable(VID_AUTH_METHOD, (WORD)pUserInfo->nAuthMethod);
    }
 
    ((NXCL_Session *)hSession)->SendMsg(&msg);
index 516061c..1cb3328 100644 (file)
@@ -83,6 +83,8 @@ static void FillUserInfoMessage(CSCPMessage *pMsg, NMS_USER *pUser)
    pMsg->SetVariable(VID_USER_SYS_RIGHTS, pUser->wSystemRights);
    pMsg->SetVariable(VID_USER_FULL_NAME, pUser->szFullName);
    pMsg->SetVariable(VID_USER_DESCRIPTION, pUser->szDescription);
+   pMsg->SetVariable(VID_GUID, pUser->guid, UUID_LENGTH);
+   pMsg->SetVariable(VID_AUTH_METHOD, (WORD)pUser->nAuthMethod);
 }
 
 
@@ -100,6 +102,7 @@ static void FillGroupInfoMessage(CSCPMessage *pMsg, NMS_USER_GROUP *pGroup)
    pMsg->SetVariable(VID_USER_SYS_RIGHTS, pGroup->wSystemRights);
    pMsg->SetVariable(VID_USER_DESCRIPTION, pGroup->szDescription);
    pMsg->SetVariable(VID_NUM_MEMBERS, pGroup->dwNumMembers);
+   pMsg->SetVariable(VID_GUID, pGroup->guid, UUID_LENGTH);
    for(i = 0, dwId = VID_GROUP_MEMBER_BASE; i < pGroup->dwNumMembers; i++, dwId++)
       pMsg->SetVariable(dwId, pGroup->pMembers[i]);
 }
@@ -1914,6 +1917,7 @@ void ClientSession::UpdateUser(CSCPMessage *pRequest)
          pRequest->GetVariableStr(VID_USER_NAME, user.szName, MAX_USER_NAME);
          user.wFlags = pRequest->GetVariableShort(VID_USER_FLAGS);
          user.wSystemRights = pRequest->GetVariableShort(VID_USER_SYS_RIGHTS);
+         user.nAuthMethod = pRequest->GetVariableShort(VID_AUTH_METHOD);
          dwResult = ModifyUser(&user);
       }
       msg.SetVariable(VID_RCC, dwResult);
index 5376c7d..d36381c 100644 (file)
@@ -69,7 +69,7 @@ BOOL LoadUsers(void)
    DWORD i, iNumRows;
 
    // Load users
-   hResult = DBSelect(g_hCoreDB, "SELECT id,name,password,system_access,flags,full_name,description,grace_logins,auth_method FROM users ORDER BY id");
+   hResult = DBSelect(g_hCoreDB, "SELECT id,name,password,system_access,flags,full_name,description,grace_logins,auth_method,guid FROM users ORDER BY id");
    if (hResult == NULL)
       return FALSE;
 
@@ -93,6 +93,7 @@ BOOL LoadUsers(void)
       nx_strncpy(g_pUserList[i].szDescription, DBGetField(hResult, i, 6), MAX_USER_DESCR);
       g_pUserList[i].nGraceLogins = DBGetFieldLong(hResult, i, 7);
       g_pUserList[i].nAuthMethod = DBGetFieldLong(hResult, i, 8);
+      DBGetFieldGUID(hResult, i, 9, g_pUserList[i].guid);
    }
 
    DBFreeResult(hResult);
@@ -120,7 +121,7 @@ BOOL LoadUsers(void)
    }
 
    // Load groups
-   hResult = DBSelect(g_hCoreDB, "SELECT id,name,system_access,flags,description FROM user_groups ORDER BY id");
+   hResult = DBSelect(g_hCoreDB, "SELECT id,name,system_access,flags,description,guid FROM user_groups ORDER BY id");
    if (hResult == 0)
       return FALSE;
 
@@ -133,6 +134,7 @@ BOOL LoadUsers(void)
       g_pGroupList[i].wSystemRights = (WORD)DBGetFieldLong(hResult, i, 2);
       g_pGroupList[i].wFlags = (WORD)DBGetFieldLong(hResult, i, 3);
       nx_strncpy(g_pGroupList[i].szDescription, DBGetField(hResult, i, 4), MAX_USER_DESCR);
+      DBGetFieldGUID(hResult, i, 5, g_pGroupList[i].guid);
       g_pGroupList[i].dwNumMembers = 0;
       g_pGroupList[i].pMembers = NULL;
    }
@@ -178,7 +180,7 @@ BOOL LoadUsers(void)
 void SaveUsers(DB_HANDLE hdb)
 {
    DWORD i;
-   char szQuery[1024], szPassword[SHA1_DIGEST_SIZE * 2 + 1];
+   char szQuery[1024], szPassword[SHA1_DIGEST_SIZE * 2 + 1], szGUID[64];
 
    // Save users
    MutexLock(m_hMutexUserAccess, INFINITE);
@@ -219,18 +221,18 @@ void SaveUsers(DB_HANDLE hdb)
          BinToStr(g_pUserList[i].szPassword, SHA1_DIGEST_SIZE, szPassword);
          if (bUserExists)
             sprintf(szQuery, "UPDATE users SET name='%s',password='%s',system_access=%d,flags=%d,"
-                             "full_name='%s',description='%s',grace_logins=%d WHERE id=%d",
+                             "full_name='%s',description='%s',grace_logins=%d,guid='%s' WHERE id=%d",
                     g_pUserList[i].szName, szPassword, g_pUserList[i].wSystemRights,
                     g_pUserList[i].wFlags, g_pUserList[i].szFullName,
                     g_pUserList[i].szDescription, g_pUserList[i].nGraceLogins,
-                    g_pUserList[i].dwId);
+                    uuid_to_string(g_pUserList[i].guid, szGUID), g_pUserList[i].dwId);
          else
-            sprintf(szQuery, "INSERT INTO users (id,name,password,system_access,flags,full_name,description,grace_logins) "
-                             "VALUES (%d,'%s','%s',%d,%d,'%s','%s',%d)",
+            sprintf(szQuery, "INSERT INTO users (id,name,password,system_access,flags,full_name,description,grace_logins,guid) "
+                             "VALUES (%d,'%s','%s',%d,%d,'%s','%s',%d,'%s')",
                     g_pUserList[i].dwId, g_pUserList[i].szName, szPassword,
                     g_pUserList[i].wSystemRights, g_pUserList[i].wFlags,
                     g_pUserList[i].szFullName, g_pUserList[i].szDescription,
-                    g_pUserList[i].nGraceLogins);
+                    g_pUserList[i].nGraceLogins, uuid_to_string(g_pUserList[i].guid, szGUID));
          DBQuery(hdb, szQuery);
       }
    }
@@ -276,15 +278,16 @@ void SaveUsers(DB_HANDLE hdb)
          // Create or update record in database
          if (bGroupExists)
             sprintf(szQuery, "UPDATE user_groups SET name='%s',system_access=%d,flags=%d,"
-                             "description='%s' WHERE id=%d",
+                             "description='%s',guid='%s' WHERE id=%d",
                     g_pGroupList[i].szName, g_pGroupList[i].wSystemRights,
                     g_pGroupList[i].wFlags, g_pGroupList[i].szDescription,
-                    g_pGroupList[i].dwId);
+                    uuid_to_string(g_pGroupList[i].guid, szGUID), g_pGroupList[i].dwId);
          else
-            sprintf(szQuery, "INSERT INTO user_groups (id,name,system_access,flags,description) "
-                             "VALUES (%d,'%s',%d,%d,'%s')",
+            sprintf(szQuery, "INSERT INTO user_groups (id,name,system_access,flags,description,guid) "
+                             "VALUES (%d,'%s',%d,%d,'%s','%s')",
                     g_pGroupList[i].dwId, g_pGroupList[i].szName, g_pGroupList[i].wSystemRights,
-                    g_pGroupList[i].wFlags, g_pGroupList[i].szDescription);
+                    g_pGroupList[i].wFlags, g_pGroupList[i].szDescription,
+                    uuid_to_string(g_pGroupList[i].guid, szGUID));
          DBQuery(hdb, szQuery);
 
          if (bGroupExists)
@@ -482,11 +485,13 @@ BOOL CheckUserMembership(DWORD dwUserId, DWORD dwGroupId)
 void DumpUsers(CONSOLE_CTX pCtx)
 {
    DWORD i;
+   char szGUID[64];
 
-   ConsolePrintf(pCtx, "Login name           System rights\n"
-                       "----------------------------------\n");
+   ConsolePrintf(pCtx, "Login name           GUID                                 System rights\n"
+                       "-----------------------------------------------------------------------\n");
    for(i = 0; i < g_dwNumUsers; i++)
-      ConsolePrintf(pCtx, "%-20s 0x%08X\n", g_pUserList[i].szName, g_pUserList[i].wSystemRights);
+      ConsolePrintf(pCtx, "%-20s %-36s 0x%08X\n", g_pUserList[i].szName,
+                    uuid_to_string(g_pUserList[i].guid, szGUID), g_pUserList[i].wSystemRights);
    ConsolePrintf(pCtx, "\n");
 }
 
@@ -579,6 +584,7 @@ DWORD CreateNewUser(char *pszName, BOOL bIsGroup, DWORD *pdwId)
          g_pGroupList[i].wFlags = UF_MODIFIED;
          g_pGroupList[i].wSystemRights = 0;
          g_pGroupList[i].szDescription[0] = 0;
+         uuid_generate(g_pGroupList[i].guid);
       }
 
       if (dwResult == RCC_SUCCESS)
@@ -610,6 +616,7 @@ DWORD CreateNewUser(char *pszName, BOOL bIsGroup, DWORD *pdwId)
          g_pUserList[i].szFullName[0] = 0;
          g_pUserList[i].szDescription[0] = 0;
          g_pUserList[i].nGraceLogins = MAX_GRACE_LOGINS;
+         uuid_generate(g_pUserList[i].guid);
       }
 
       if (dwResult == RCC_SUCCESS)
@@ -647,6 +654,7 @@ DWORD ModifyUser(NMS_USER *pUserInfo)
          strcpy(g_pUserList[i].szName, pUserInfo->szName);
          strcpy(g_pUserList[i].szFullName, pUserInfo->szFullName);
          strcpy(g_pUserList[i].szDescription, pUserInfo->szDescription);
+         g_pUserList[i].nAuthMethod = pUserInfo->nAuthMethod;
          
          // We will not replace system access rights for UID 0
          if (g_pUserList[i].dwId != 0)
index b666513..fbeeaf1 100644 (file)
@@ -313,6 +313,8 @@ double LIBNXSRV_EXPORTABLE DBGetFieldDouble(DB_RESULT hResult, int iRow, int iCo
 DWORD LIBNXSRV_EXPORTABLE DBGetFieldIPAddr(DB_RESULT hResult, int iRow, int iColumn);
 BOOL LIBNXSRV_EXPORTABLE DBGetFieldByteArray(DB_RESULT hResult, int iRow, int iColumn,
                                              int *pnArray, int nSize, int nDefault);
+BOOL LIBNXSRV_EXPORTABLE DBGetFieldGUID(DB_RESULT hResult, int iRow,
+                                        int iColumn, uuid_t guid);
 char LIBNXSRV_EXPORTABLE *DBGetFieldAsync(DB_ASYNC_RESULT hResult, int iColumn, char *pBuffer, int iBufSize);
 LONG LIBNXSRV_EXPORTABLE DBGetFieldAsyncLong(DB_RESULT hResult, int iColumn);
 DWORD LIBNXSRV_EXPORTABLE DBGetFieldAsyncULong(DB_ASYNC_RESULT hResult, int iColumn);
index b6748f4..c788da5 100644 (file)
@@ -360,6 +360,38 @@ BOOL LIBNXSRV_EXPORTABLE DBGetFieldByteArray(DB_RESULT hResult, int iRow, int iC
 
 
 //
+// Get field's value as GUID
+//
+
+BOOL LIBNXSRV_EXPORTABLE DBGetFieldGUID(DB_RESULT hResult, int iRow,
+                                        int iColumn, uuid_t guid)
+{
+   char *pszVal;
+   BOOL bResult;
+
+   pszVal = DBGetField(hResult, iRow, iColumn);
+   if (pszVal != NULL)
+   {
+      if (uuid_parse(pszVal, guid) == 0)
+      {
+         bResult = TRUE;
+      }
+      else
+      {
+         uuid_clear(guid);
+         bResult = FALSE;
+      }
+   }
+   else
+   {
+      uuid_clear(guid);
+      bResult = FALSE;
+   }
+   return bResult;
+}
+
+
+//
 // Get number of rows in result
 //
 
index f3b221b..6ba0dee 100644 (file)
@@ -35,6 +35,7 @@
 #endif   /* _WIN32 */
 
 #include <nms_util.h>
+#include <uuid.h>
 #include <nms_agent.h>
 #include <nms_threads.h>
 #include <dbdrv.h>
index 47a85e8..da25522 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** nxdbmgr - NetXMS database manager
-** Copyright (C) 2004, 2005 Victor Kirhenshtein
+** Copyright (C) 2004, 2005, 2006 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
index 2a2f82a..39b06e9 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <nms_common.h>
 #include <nms_util.h>
+#include <uuid.h>
 #include <nxsrvapi.h>
 #include <netxmsdb.h>
 
index e97cafc..2c57a6a 100644 (file)
@@ -78,6 +78,95 @@ static BOOL CreateConfigParam(TCHAR *pszName, TCHAR *pszValue, int iVisible, int
 
 
 //
+// Upgrade from V40 to V41
+//
+
+static BOOL H_UpgradeFromV40(void)
+{
+   static TCHAR m_szBatch[] =
+      "ALTER TABLE users ADD guid varchar(36)\n"
+      "ALTER TABLE users ADD auth_method integer\n"
+      "ALTER TABLE user_groups ADD guid varchar(36)\n"
+      "UPDATE users SET auth_method=0\n"
+      "<END>";
+   DB_RESULT hResult;
+   int i, nCount;
+   DWORD dwId;
+   uuid_t guid;
+   TCHAR szQuery[256], szGUID[64];
+
+   if (!SQLBatch(m_szBatch))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   // Generate GUIDs for users and groups
+   printf("Generating GUIDs...\n");
+   
+   hResult = SQLSelect(_T("SELECT id FROM users"));
+   if (hResult != NULL)
+   {
+      nCount = DBGetNumRows(hResult);
+      for(i = 0; i < nCount; i++)
+      {
+         dwId = DBGetFieldULong(hResult, i, 0);
+         uuid_generate(guid);
+         _sntprintf(szQuery, 256, _T("UPDATE users SET guid='%s' WHERE id=%d"),
+                    uuid_to_string(guid, szGUID), dwId);
+         if (!SQLQuery(szQuery))
+            if (!g_bIgnoreErrors)
+            {
+               DBFreeResult(hResult);
+               return FALSE;
+            }
+      }
+      DBFreeResult(hResult);
+   }
+
+   hResult = SQLSelect(_T("SELECT id FROM user_groups"));
+   if (hResult != NULL)
+   {
+      nCount = DBGetNumRows(hResult);
+      for(i = 0; i < nCount; i++)
+      {
+         dwId = DBGetFieldULong(hResult, i, 0);
+         uuid_generate(guid);
+         _sntprintf(szQuery, 256, _T("UPDATE user_groups SET guid='%s' WHERE id=%d"),
+                    uuid_to_string(guid, szGUID), dwId);
+         if (!SQLQuery(szQuery))
+            if (!g_bIgnoreErrors)
+            {
+               DBFreeResult(hResult);
+               return FALSE;
+            }
+      }
+      DBFreeResult(hResult);
+   }
+
+   if (!CreateConfigParam(_T("RADIUSServer"), _T("localhost"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("RADIUSSecret"), _T("netxms"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("RADIUSNumRetries"), _T("5"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("RADIUSTimeout"), _T("3"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!SQLQuery(_T("UPDATE config SET var_value='41' WHERE var_name='DBFormatVersion'")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   return TRUE;
+}
+
+
+//
 // Upgrade from V39 to V40
 //
 
@@ -1733,6 +1822,7 @@ static struct
    { 37, H_UpgradeFromV37 },
    { 38, H_UpgradeFromV38 },
    { 39, H_UpgradeFromV39 },
+   { 40, H_UpgradeFromV40 },
    { 0, NULL }
 };