skafy Posted December 23, 2015 Author Share Posted December 23, 2015 in client code "MainForm.ClientEvents.ExtEvents.Show" (for example) function window.show(sender, eOpts) { var WinNetwork = new ActiveXObject("WScript.Network"); ajaxRequest(sender, 'UserDetailsEvent', ['UserName='+WinNetwork.UserName]); } in server code: procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName='UserDetailsEvent' then begin UniEdit1.Text:=Params.Values['UserName']; end; end; It seems like UniFormAjaxEvent doesn't catch/fire UserDetailsEvent. When I debug EventName is equal to cinfo, afterrender and resize. I've put AjaxRequest in window.show. function window.show(sender, eOpts) { var WinNetwork = new ActiveXObject("WScript.Network"); ajaxRequest(sender, 'UserDetailsEvent', ['UserName='+WinNetwork.UserName]); } and call function UniFormAjaxEvent in main form Main (renamed MainForm) procedure TMain.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName='UserDetailsEvent' then begin CurrentUser:= Params.Values['UserName']; WorkflowDM.SetUp(CurrentUser); lblCurrentUser.Caption:= WorkflowDM.GetCurrentUserName; end; end; What am I doing wrong here. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2015 Share Posted December 23, 2015 Hi, Seems all is correct.. call function UniFormAjaxEvent in main form Main (renamed MainForm) ??? - Check please again.. 1 Quote Link to comment Share on other sites More sharing options...
skafy Posted December 23, 2015 Author Share Posted December 23, 2015 I've put this simple line of code in windows.show simple alert code and "Hello ExtJS" doesn't pop up. What could be wrong? function window.show(sender, eOpts) { alert("Hello ExtJS"); } Hi, Seems all is correct.. call function UniFormAjaxEvent in main form Main (renamed MainForm) ??? - Check please again.. yes. I renamed default named MainForm to Main Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2015 Share Posted December 23, 2015 Hi, I'm sorry, maybe in your project somewhere there is a mistake,but it works for me, also works ajaxRequest: Can you make a simple testcase ?! Best regards. Quote Link to comment Share on other sites More sharing options...
bugra Posted December 23, 2015 Share Posted December 23, 2015 Hi It works in this project Clientusername.zip But your ie settings must change. in security you must add your website in trusted sites and click custom level enable Initialize and script Activex controls not marked as safe for scripting option. 1 Quote Link to comment Share on other sites More sharing options...
skafy Posted December 23, 2015 Author Share Posted December 23, 2015 Hi, I'm sorry, maybe in your project somewhere there is a mistake, but it works for me, also works ajaxRequest: Can you make a simple testcase ?! Best regards. I think I found the problem. In the ServerModule I have set MainFormDisplayMode to mfPage. Can you confirm? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 23, 2015 Administrators Share Posted December 23, 2015 I think I found the problem. In the ServerModule I have set MainFormDisplayMode to mfPage. Can you confirm? Yes, in this case show event is not fired. You need to use another event such as form.afterrender perhaps. 1 Quote Link to comment Share on other sites More sharing options...
skafy Posted December 23, 2015 Author Share Posted December 23, 2015 I've reproduced the problem. -MainFormDisplayMode is mfPage -Code is in form.afterrender Project: http://amshare.adria-mobil.si//ZAWD5EZVCP78/Clientusername.zip.html Quote Link to comment Share on other sites More sharing options...
bugra Posted December 23, 2015 Share Posted December 23, 2015 Hi Skafy. In your project code is in wrong client-event. It isn't in window.afterrender. Change Ext.window.Window to Ext.form.Panel and put your code in form.afterrender. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2015 Share Posted December 23, 2015 Quote Link to comment Share on other sites More sharing options...
skafy Posted December 23, 2015 Author Share Posted December 23, 2015 wow..It is working now at last. Thank you all for help and kindness. Quote Link to comment Share on other sites More sharing options...
DoiSuthep Posted November 25, 2016 Share Posted November 25, 2016 Hi, Has anyone been able to retrieve widows client username without ActiveXObject. I am looking for something not IE-only restricted. My web Server is IIS 8. Quote Link to comment Share on other sites More sharing options...
skafy Posted November 28, 2016 Author Share Posted November 28, 2016 When I investigate i couldn't find another option. When I think of it now, I will probably change it so user will have to put its credentials once and I would then save it with cookies(would check whid LDAP). It would cover multiple browser insted of just IE. Quote Link to comment Share on other sites More sharing options...
skafy Posted June 21, 2017 Author Share Posted June 21, 2017 Now when I applied SSL for HTTPS connection with certificate I'm having same problem as before. "Automation server can not create object". Does enybody know why is this happening? Quote Link to comment Share on other sites More sharing options...
skafy Posted June 22, 2017 Author Share Posted June 22, 2017 I've managed to fix it. Problem occured because I had the ServerModule port and SSL port the same. I fix it with change it so Port is 80 and SSL Port is 443. Quote Link to comment Share on other sites More sharing options...
naozuka Posted July 4, 2018 Share Posted July 4, 2018 Ok. This is solved. procedure TMain.UniFormCreate(Sender: TObject); begin UniSession.AddJS('var WinNetwork = new ActiveXObject("WScript.Network");'); UniSession.AddJS('alert(WinNetwork.UserName);'); end; This pops up domain name of currently logged in user. Now I wonder how to get this WinNetwork.Username in a variable in outside JS. Eny ideas? This is not a best practice since: 1) Your user may not be on Internet Explorer. 2) Your user may not be with ActiveX enabled. The best practice is to get the logged user on your application and save that as a log. BUT if you really want this way you need ajaxRequest. procedure TMainForm.UniFormCreate(Sender: TObject); begin UniSession.AddJS('var WinNetwork = new ActiveXObject("WScript.Network");'); UniSession.AddJS('ajaxRequest(MainForm.UniLabel1, ''WindowsUser'',[''username=''+WinNetwork.UserName]);'); end; procedure TMainForm.UniLabel1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='WindowsUser' then begin UniLabel1.Caption := 'UserName: ' + Params['username'].AsString; end; end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.