Scense
Can you convert active directory Firstname/Lastname/Department to Variables? - Printable Version

+- Scense (http://www.scense.com/forum)
+-- Forum: Scense User Group (http://www.scense.com/forum/forumdisplay.php?fid=1)
+--- Forum: Help & Troubleshooting (http://www.scense.com/forum/forumdisplay.php?fid=5)
+--- Thread: Can you convert active directory Firstname/Lastname/Department to Variables? (/showthread.php?tid=118)



Can you convert active directory Firstname/Lastname/Department to Variables? - JVD - 09-25-2020

I would like to use our active directory lastname, firstname, email adress, department to variables so we can use it in application with a... i presume: %Firstname%, %Lastname%, %Department% variable?

How can we establish this?


RE: Can you convert active directory Firstname/Lastname/Department to Variables? - ScenseGuru - 09-27-2020

Hi,

There are ways of doing this with Scense internal variables backed by System Parameters, but probably the easiest way of doing this is by adding a Scripting Action to your logon script with the following content:

Code:
Sub Scense_Main()
    ' Prepare the environment accessor
    Set wshShell = CreateObject( "WScript.Shell" )
    Set wshUserEnv = wshShell.Environment("USER")
   
    ' Reference the current user
    Set objSysInfo = CreateObject("ADSystemInfo")   
    Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
   
    ' Set the environment variables
    wshUserEnv("FirstName") = objUser.givenName
    wshUserEnv("LastName") = objUser.lastName
    wshUserEnv("Department") = objUser.department
End Sub

After executing this scripting action you can use these variables the way you suggested.

Cheers