RogFleming Posted June 29, 2011 Author Share Posted June 29, 2011 additonal infromation I found seems int eh sample C++ code the following is done to get the user data: m_idXyLocKey = user_info.XyLocKeyID; m_strSystemAccountName = user_info.SystemAccountName; m_strPersonalName = user_info.PersonalName; m_stateXyLoc = user_info.XyLocState; expandcollapse popup// ETWSSAPIDemo.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "ETWSSAPIDemo.h" #include "ETWSSAPIDemoDlg.h" #include "Helper.h" #include "UserRegistrationDlg.h" #include "ManualLoginDlg.h" #include "ETWSSAPI.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CETWSSAPIDemoApp BEGIN_MESSAGE_MAP(CETWSSAPIDemoApp, CWinApp) //{{AFX_MSG_MAP(CETWSSAPIDemoApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CETWSSAPIDemoApp construction CETWSSAPIDemoApp::CETWSSAPIDemoApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance m_idXyLocKey = -1; m_strSystemAccountName = ""; m_strPersonalName = ""; m_strUsername = ""; m_strPassword = ""; m_cUsers = 0; } ///////////////////////////////////////////////////////////////////////////// // The one and only CETWSSAPIDemoApp object CETWSSAPIDemoApp theApp; ///////////////////////////////////////////////////////////////////////////// // CETWSSAPIDemoApp initialization BOOL CETWSSAPIDemoApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // Initialize the ET WSS API WSS_CODE wssCode = WSSInit (WSSAPI_VERSION_MAJOR, WSSAPI_VERSION_MINOR); if (WSS_OK != wssCode) { ShowErrorMsg (wssCode); return FALSE; } // load user record if (!LoadUsers ()) { WSSTerminate (); return FALSE; } if (!AuthenticateUser ()) { WSSTerminate (); return FALSE; } CETWSSAPIDemoDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Uninitialize WSS API WSSTerminate (); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; } BOOL CETWSSAPIDemoApp::LoadUsers () { FILE * fpUser = fopen ("userinfo.txt", "r"); if (fpUser == NULL) { // No user info file ::AfxMessageBox ("Cannot open userinfo.txt file!", MB_OK); return FALSE; } else { while (TRUE) { int ret = fscanf (fpUser, "%s %s", m_userRec[m_cUsers].szUsername, m_userRec[m_cUsers].szPassword); if (ret == EOF || ret == 0) break; m_cUsers++; // 10 records max for demo if (m_cUsers >= 10) break; } fclose (fpUser); return TRUE; } } BOOL CETWSSAPIDemoApp::CheckUser (long idXyLocKey, CString & strUsername, CString & strPassword) { BOOL bFoundUser = FALSE; for (int i = 0; i < m_cUsers; i++) { if ((strUsername == m_userRec[i].szUsername && strPassword == m_userRec[i].szPassword)) { strUsername = m_userRec[i].szUsername; strPassword = m_userRec[i].szPassword; bFoundUser = TRUE; break; } } return bFoundUser; } BOOL CETWSSAPIDemoApp::AuthenticateUser() { USER_INFO user_info; // Ask XyLoc for current user information WSS_CODE wssCode = WSSGetUserInfo (&user_info); if (WSS_OK != wssCode) { ShowErrorMsg (wssCode); return FALSE; } // if the PC is locked, abort the authentication if (WSS_LOCKED == user_info.XyLocState) return FALSE; // if the PC is unlocked by user manual ovdrride, do manual login if (WSS_OVERRIDE == user_info.XyLocState) { CManualLoginDlg dlg; if (IDOK == dlg.DoModal ()) { if (CheckUser (-1, dlg.m_strUsername, dlg.m_strPassword)) { m_idXyLocKey = user_info.XyLocKeyID; m_strSystemAccountName = user_info.SystemAccountName; m_strPersonalName = user_info.PersonalName; m_stateXyLoc = user_info.XyLocState; m_strUsername = dlg.m_strUsername; m_strPassword = dlg.m_strPassword; return TRUE; } else { ::AfxMessageBox ("Authenetication Failed!", MB_OK); return FALSE; } } else { return FALSE; } } else { // XyLoc Key is present, authenticate the user using XyLoc key char szParam[64]; memset (szParam, 0, sizeof szParam); int len = sizeof (szParam); // retrieve the param in Ensure Store wssCode = WSSReadParamOffline (ET_WSS_DEMO_APP_ID, user_info.XyLocKeyID, szParam, &len); if (WSS_OK == wssCode) { CString strParam (szParam); int idx = strParam.Find (','); m_strUsername = strParam.Left (idx); m_strPassword = strParam.Right (strParam.GetLength () - idx - 1); } else { m_strUsername = ""; m_strPassword = ""; } if (!CheckUser (user_info.XyLocKeyID, m_strUsername, m_strPassword)) { // User is not register with XyLoc, register it now CUserRegistrationDlg dlg (user_info.XyLocKeyID, user_info.SystemAccountName, user_info.PersonalName); if (IDOK == dlg.DoModal ()) { // check the user's credential and register it if (CheckUser (user_info.XyLocKeyID, dlg.m_strUsername, dlg.m_strPassword)) { m_idXyLocKey = user_info.XyLocKeyID; m_strSystemAccountName = user_info.SystemAccountName; m_strPersonalName = user_info.PersonalName; m_stateXyLoc = user_info.XyLocState; m_strUsername = dlg.m_strUsername; m_strPassword = dlg.m_strPassword; // store the parameter to Ensure Store char szParam[64]; sprintf (szParam, "%s,%s", (LPCSTR)m_strUsername, (LPCSTR)m_strPassword); wssCode = WSSWriteParamOffline (ET_WSS_DEMO_APP_ID, user_info.XyLocKeyID, szParam, strlen (szParam)); if (WSS_OK != wssCode) { ShowErrorMsg (wssCode); } return TRUE; } else { ::AfxMessageBox ("Authenetication Failed!", MB_OK); return FALSE; } } else { ::AfxMessageBox ("Authenetication Failed!", MB_OK); return FALSE; } } else { m_idXyLocKey = user_info.XyLocKeyID; m_strSystemAccountName = user_info.SystemAccountName; m_strPersonalName = user_info.PersonalName; m_stateXyLoc = user_info.XyLocState; return TRUE; } } } expandcollapse popup// ETWSSAPIDemo.h : main header file for the ETWSSAPIDEMO application // #if !defined(AFX_ETWSSAPIDEMO_H__4AFD3E3D_801D_4104_8A49_3D44CAB36824__INCLUDED_) #define AFX_ETWSSAPIDEMO_H__4AFD3E3D_801D_4104_8A49_3D44CAB36824__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols #define ET_WSS_DEMO_APP_ID 1001 typedef struct { char szUsername[256]; char szPassword[64]; } USER_RECORD; ///////////////////////////////////////////////////////////////////////////// // CETWSSAPIDemoApp: // See ETWSSAPIDemo.cpp for the implementation of this class // class CETWSSAPIDemoApp : public CWinApp { public: CETWSSAPIDemoApp(); private: long m_idXyLocKey; int m_stateXyLoc; CString m_strSystemAccountName; CString m_strPersonalName; CString m_strUsername; CString m_strPassword; //Application User Record int m_cUsers; USER_RECORD m_userRec[10]; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CETWSSAPIDemoApp) public: virtual BOOL InitInstance(); //}}AFX_VIRTUAL // Implementation //{{AFX_MSG(CETWSSAPIDemoApp) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() private: BOOL LoadUsers (); public: BOOL AuthenticateUser(); BOOL CheckUser (long idXyLocKey, CString & strUsername, CString & strPassword); long GetXyLocKeyID () { return m_idXyLocKey; } CString & GetSystemAccountName () { return m_strSystemAccountName; } CString & GetPersonalName () { return m_strPersonalName; } CString & GetUsername () { return m_strUsername; } void SetXyLocKeyID (long idKey) { m_idXyLocKey = idKey; } void SetSystemAccountName (CString & strSystemAccountName) { m_strSystemAccountName = strSystemAccountName; } void SetPersonalName (CString & strPersonalName) { m_strPersonalName = strPersonalName; } void SetUsername (CString & strUsername) { m_strUsername = strUsername; } void SetPassword (CString & strPassword) { m_strPassword = strPassword; } void SetXyLocState (int stateXyLoc) { m_stateXyLoc = stateXyLoc; } }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_ETWSSAPIDEMO_H__4AFD3E3D_801D_4104_8A49_3D44CAB36824__INCLUDED_) Link to comment Share on other sites More sharing options...
jchd Posted June 29, 2011 Share Posted June 29, 2011 OK I've setup a couple of enums and fixed the parameter type. What gives: #include<array.au3> #cs ; WSS_CODE XSO_OK XSO_NOT_INITED XSO_NOT_RESPONDING XSO_INTERNAL_ERROR ; USER_INFO typedef struct _USER_INFO { long TestAppKeyID; char SystemAccountName[MAX_NAME_LEN]; char PersonalName[MAX_NAME_LEN]; XSO_STATE TestAppState; } USER_INFO; 3.5 WSS_STATE typedef enum WSS_STATE { WSS_UNKNOWN_STATE = 0, WSS_LOCKED, WSS_UNLOCKED, WSS_OVERRIDE, } WSS_STATE; WSS_UNKNOWN_STATE Unknown State WSS_LOCKED PC is locked WSS_UNLOCKED PC is unlocked by XyLoc Key WSS_OVERRIDE PC is unlocked by user manual override 4.3 WSSGetUserInfo Prototype: WSS_CODE WSSGetUserInfo(USER_INFO * userInfo) Arguments: userInfo The current user info to return Return Value: WSS_OK WSS_NOT_INITED WSS_NOT_RESPONDING WSS_INTERNAL_ERROR #ce ;; WSS_STATE Local enum _ ; WSS_STATE $WSS_UNKNOWN_STATE = 0, _ ; Unknown State $WSS_LOCKED, _ ; PC is locked $WSS_UNLOCKED, _ ; PC is unlocked by XyLoc Key $WSS_OVERRIDE ; PC is unlocked by user manual override ;; WSS_CODE (guess it's an enum starting at 0) Local enum _ ; WSS_CODE $XSO_OK = 0, _ ; $XSO_NOT_INITED, _ ; $XSO_NOT_RESPONDING, ; $XSO_INTERNAL_ERROR ; Global $h_ETWSSDLL Global $XylocStart $p = DllStructCreate("long XyLocKeyID; char SystemAccountName[126]; char PersonalName[126]; int AppState") ;~ DllStructSetData($p, "userInfo", DllStructGetSize($p)) ;; doesn't make sense: which member is "userInfo"? ;make the DllCall $h_ETWSSDLL = DllOpen("ETWSS.DLL") If $h_ETWSSDLL = -1 Then ConsoleWrite("OpenDll Failed: " & $h_ETWSSDLL & @LF) Exit EndIf ; call the dll to initiate $XylocStart = DllCall($h_ETWSSDLL, "int", "WSSInit", "int", 4, "int", 1) ConsoleWrite("Starting ETWSS.dll: " & $XylocStart & @CRLF) $ret = DllCall($h_ETWSSDLL, "int", "WSSGetUserInfo", "ptr", DllStructGetPtr($p)) If @error Then ConsoleWrite("DllCall Error: " & @error & @CRLF) Exit EndIf _ArrayDisplay($ret) If Not $ret[0] Then ConsoleWrite("Get User Info returned: " & $ret[0] & @CRLF) Exit EndIf ;get the returned values $XylocID = DllStructGetData($p, "XyLocKeyID") $XylocUser = DllStructGetData($p, "SystemAccountName") $PersonalName = DllStructGetData($p, "PersonalName") $AppState = DllStructGetData($p, "AppState") ;free the struct $p = 0 ConsoleWrite("OS Arch:" & @OSArch & @CRLF) ConsoleWrite("Xyloc ID: " & $XylocID & @CRLF) ConsoleWrite("XylocUser: " & $XylocUser & @CRLF) ConsoleWrite("PersonalName: " & $PersonalName & @CRLF) ; need to have info on AppState to display meaningful data DllCall($h_ETWSSDLL, "int", "WSSTerminate") DllClose($h_ETWSSDLL) What do I miss? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RogFleming Posted June 29, 2011 Author Share Posted June 29, 2011 Perfection : had a make one small change but it works: thanks for the learning experience, now I goging to dive into the LDAP dll next, which would resolve having to export and import ldif files with ldapsearch and ldapmodify, I seen many in forums looking for solutions. expandcollapse popup;; WSS_STATE Local enum _ ; WSS_STATE $WSS_UNKNOWN_STATE = 0, _ ; Unknown State $WSS_LOCKED, _ ; PC is locked $WSS_UNLOCKED, _ ; PC is unlocked by XyLoc Key $WSS_OVERRIDE ; PC is unlocked by user manual override ;; WSS_CODE (guess it's an enum starting at 0) Local enum _ ; WSS_CODE $WSS_OK = 0, _ ; $WSS_NOT_INITED, _ ; $WSS_NOT_RESPONDING, _ ; $WSS_INTERNAL_ERROR ; Global $h_ETWSSDLL Global $XylocStart $p = DllStructCreate("long XyLocKeyID; char SystemAccountName[126]; char PersonalName[126]; int AppState") ;make the DllCall $h_ETWSSDLL = DllOpen("ETWSS.DLL") If $h_ETWSSDLL = -1 Then ConsoleWrite("OpenDll Failed: " & $h_ETWSSDLL & @LF) Exit EndIf ; call the dll to initiate $XylocStart = DllCall($h_ETWSSDLL, "int", "WSSInit", "int", 4, "int", 1) ConsoleWrite("Starting ETWSS.dll: " & $XylocStart & @CRLF) $ret = DllCall($h_ETWSSDLL, "int", "WSSGetUserInfo", "ptr", DllStructGetPtr($p)) If @error Then ConsoleWrite("DllCall Error: " & @error & @CRLF) Exit EndIf If Not $ret[0] Then ConsoleWrite("Get User Info returned: " &$p&":"&$ret[0] & @CRLF) EndIf ;get the returned values $XylocID = DllStructGetData($p, "XyLocKeyID") $XylocUser = DllStructGetData($p, "SystemAccountName") $PersonalName = DllStructGetData($p, "PersonalName") $XylocState = DllStructGetData($p, "AppState") ;free the struct $p = 0 ConsoleWrite("Xyloc ID: " & $XylocID & @CRLF) ConsoleWrite("XylocUser: " & $XylocUser & @CRLF) ConsoleWrite("PersonalName: " & $PersonalName & @CRLF) ConsoleWrite("Xyloc Status: " & $XylocState & @CRLF) ; need to have info on AppState to display meaningful data DllCall($h_ETWSSDLL, "int", "WSSTerminate") DllClose($h_ETWSSDLL) Link to comment Share on other sites More sharing options...
jchd Posted June 29, 2011 Share Posted June 29, 2011 Sorry for numerous delays in following your thread, had too many urgent stuff banging my back. Glad if it can be useful for your project. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RogFleming Posted July 18, 2011 Author Share Posted July 18, 2011 well the DLL integration went very well except in one case, if we try to publish the script as a Citrix published application we get the following error:displays through the gui, they both crash with:“Debug Assertion Failed!”DLLReader.exe File: fprintf.c Line 56Expression: str != NULL Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now