Page 1 of 1
Detect Active Directory User on SQL-Server
Posted: Thu Jul 14, 2022 3:40 pm
by Weissnix
Hello together,
we are using Visual Lansa for Web. Is there any possibility when running the program on SQL server to detect the Active Directory user?
Or is a login screen the only way to recognize the user?
Re: Detect Active Directory User on SQL-Server
Posted: Thu Jul 14, 2022 11:09 pm
by Dino
A server routine in a server module is needed to access that kind of resources and start the session, the login screen is just a way to get there, not required.
saying so, there is an example in the package manager, to login with microsoft.
Maybe that example can point you to a way to make it work.

- microsoft01.png (106.69 KiB) Viewed 8094 times
Re: Detect Active Directory User on SQL-Server
Posted: Thu Jul 14, 2022 11:23 pm
by Dino
i guess this is a silly example, as I dont have active directory to test, but if i create a web page like this:
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)
Define_Com Class(#STD_STRNG.EditField) Name(#STD_STRNG) DisplayPosition(1) Left(28) Parent(#COM_OWNER) TabPosition(1) Top(18) Width(381)
Evtroutine Handling(#Com_owner.Initialize)
Define_Com Class(#test714sm.whoami) Name(#whoami)
#whoami.Execute STD_STRNG(#STD_STRNG)
Endroutine
End_Com
and a server module (#test714sm) like this:
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_SRVM)
Srvroutine Name(whoami)
Field_Map For(*Output) Field(#STD_STRNG)
Def_List Name(#whoami) Fields(#STD_STRNG) Type(*Working) Entrys(1)
Use Builtin(SYSTEM_COMMAND) With_Args("B" 'whoami > c:\temp\whoami.txt') To_Get(#STD_NUM)
Use Builtin(transform_file) With_Args(#whoami 'c:\temp\whoami.txt') To_Get(#io$sts)
Get_Entry Number(1) From_List(#whoami)
Endroutine
End_Com
I think I could get there.

- microsoft02.png (16.05 KiB) Viewed 8094 times
Re: Detect Active Directory User on SQL-Server
Posted: Fri Jul 15, 2022 4:47 pm
by Weissnix
Unfortunately, I can not call the examples. As soon as I click on the Package Manager the message appears:
A fatal error has occured. Lansa Tools was unable to download the required application files. Please contact Lansa Support
Great thanks for the info and the tip with "whoami" and saving to a text file. I will try it.
-------
When I use the whoami locally on my environment, I get the Active Directory user.
If I call the program from my browser on the mysql server, I get the database user accessing the SQL database.
Re: Detect Active Directory User on SQL-Server
Posted: Sat Jul 16, 2022 12:04 am
by Dino
try again the package, it is working now (I am in V15 epc 150040):

- packages01.png (28.3 KiB) Viewed 8070 times