Detect Active Directory User on SQL-Server

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
Weissnix
Posts: 5
Joined: Mon Dec 10, 2018 5:05 pm
Location: Germany

Detect Active Directory User on SQL-Server

Post 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?
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Detect Active Directory User on SQL-Server

Post 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
microsoft01.png (106.69 KiB) Viewed 8093 times
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Detect Active Directory User on SQL-Server

Post 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
microsoft02.png (16.05 KiB) Viewed 8093 times
User avatar
Weissnix
Posts: 5
Joined: Mon Dec 10, 2018 5:05 pm
Location: Germany

Re: Detect Active Directory User on SQL-Server

Post 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.
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Detect Active Directory User on SQL-Server

Post by Dino »

try again the package, it is working now (I am in V15 epc 150040):
packages01.png
packages01.png (28.3 KiB) Viewed 8069 times
Post Reply