Atl Xojo Users Group - Mon, Apr 11, 2016

Hello Xojo enthusiasts!

Please join us for this Xojo monthly meeting! We promise that you’ll learn something new at each meeting!

Who: Everyone interested in developing in Xojo!
What: Monthly Meeting
Where: Las Palmas Mexian Restaurant , 2210 Holly Springs Pkwy, Holly Springs, GA :: 770-720-0062
When: Monday, April 11th, 2016 – 6pm to 9pm
Topic:
If you want to get in with the MicroSoft boys, that probably means making your Xojo application work with Active Directory. We’ll take a look at how to authenticate your desktop and web apps with Active Directory so that it keeps one point of front door authentication.

We’ve got the latest Xojo news, reviews and announcements.

Do y’all have a video record of this meeting anywhere? I am trying to create a log in for my web apps that use active directory and would love to view the meet up if its available.

Thank you.

Hello Derek,

We don’t record our meetings currently. Nobody wants to watch us eat. Here’s the code I’m using for active directory login. Note that this is an Intranet application that is behind a firewall. If you’re making it public facing, I’d throw in all sorts of additional validations. I hope this helps.

[code]Dim strUser, strPassword, strQuery As String
DIM strMessage AS String = “”
DIM dblStartTime, dblEndTime, dblTimeSpent AS Double
DIM bolContinue AS Boolean = False
DIM oDate AS New Date

self.lblMessage.Text = “Please wait. Checking login…”

strUser = tADUser
strPassword = tADPassword
dim LogonServer as string
LogonServer = ReplaceAll(system.EnvironmentVariable(“LOGONSERVER”), “”, “”)
self.lblMessage.Text = "LogonServer: " + LogonServer

Dim adoConnection, adoCommand,adoRecordset As OleObject

strQuery = “SELECT cn FROM 'LDAP://” + LogonServer + "’ WHERE ObjectClass=’*’ "
strUser = “YOURDOMAINHERE” + TRIM( strUser )

dblStartTime = Microseconds
adoConnection = new OLEOBJECT(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOOBJECT”
adoConnection.Properties(“User ID”) = strUser
adoConnection.Properties(“Password”) = strPassword
adoConnection.Properties(“Encrypt Password”) = false
adoConnection.open (“DS Query”, strUser, strPassword)
dblEndTime = Microseconds
dblTimeSpent = ( dblEndTime - dblStartTime ) / 1000000
strMessage = oDate.LongTime + " " + CSTR( dblTimeSpent ) + " seconds to get the user connection."

adoCommand = New OleObject(“ADODB.Command”)
adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = strQuery
adoCommand.Properties(“Size Limit”) = 1

adoRecordset = New OLEObject(“ADODB.Recordset”)

dblStartTime = Microseconds
Try
adoRecordset = adoCommand.Execute()

// User managed to login
self.lblMessage.Text = strUser+" managed to login on Active Directory Server: "+ LogonServer
Session.StoreUser( tADUser )
bolContinue = True

Catch ExecuteError As OLEException
// User did not manage to login
DIM oNow AS NEW DATE
DIM cMessage AS String = “Unknown user name or invalid password. Please check your settings and try again. [” + oNow.ShortTime + “]”
session.LogActivity( “ActiveDirectoryLogon”, “Unknown user name or password: " + strUser )
self.lblMessage.Text = cMessage
End Try
dblEndTime = Microseconds
dblTimeSpent = (dblEndTime - dblStartTime ) / 1000000
strMessage = oDate.LongTime + " " + CSTR( dblTimeSpent ) + " seconds to log " + strUser + " on.”
Session.LogActivity( “ActiveDirectoryLogon”, strMessage )

adoConnection.close
adoConnection = Nil
adoCommand = Nil
adoRecordset = Nil

IF bolContinue THEN
DIM strEmployeeEmail AS String = Session.GetEmployeeActive( tADUser )
Session.cUserEmail = strEmployeeEmail
END IF

IF bolContinue THEN
DIM cMessage AS String = oDate.AbbreviatedDate + " " + oDate.LongTime + " " + tADUser + " logged in."
Session.LogActivity( “ActiveDirectoryLogon”, cMessage )
MainMenu.Show()
END

exception err as oleexception
self.lblMessage.Text = "Error: " + err.Message[/code]

Kevin, thank you so much. This is very helpful!