mirror of
https://github.com/jakobadam/RDSFactor.git
synced 2025-06-14 00:14:41 +02:00
Rename CICRadarR -> RDSFactor
This commit is contained in:
parent
d296781847
commit
a29384d872
40 changed files with 810 additions and 810 deletions
|
@ -1,7 +1,7 @@
|
||||||
Imports System.ServiceProcess
|
Imports System.ServiceProcess
|
||||||
|
|
||||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||||
Partial Class CICRadarR
|
Partial Class RDSFactor
|
||||||
Inherits System.ServiceProcess.ServiceBase
|
Inherits System.ServiceProcess.ServiceBase
|
||||||
|
|
||||||
'UserService overrides dispose to clean up the component list.
|
'UserService overrides dispose to clean up the component list.
|
||||||
|
@ -28,7 +28,7 @@ Partial Class CICRadarR
|
||||||
'
|
'
|
||||||
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
|
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
|
||||||
'
|
'
|
||||||
Dim server = New CICRadarR()
|
Dim server = New RDSFactor()
|
||||||
|
|
||||||
If Environment.UserInteractive Then
|
If Environment.UserInteractive Then
|
||||||
server.OnStart(args)
|
server.OnStart(args)
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Express 2013 for Windows Desktop
|
# Visual Studio Express 2013 for Windows Desktop
|
||||||
VisualStudioVersion = 12.0.31101.0
|
VisualStudioVersion = 12.0.31101.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CICRadarR", "CICRadarR.vbproj", "{04C6C533-9FEA-41B2-B554-A166C7C7FE32}"
|
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RDSFactor", "RDSFactor.vbproj", "{04C6C533-9FEA-41B2-B554-A166C7C7FE32}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RADAR", "..\radar-radius\RADAR\RADAR.vbproj", "{3AB08A4E-C4FA-4571-A5D4-32BBA807C31D}"
|
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RADAR", "..\radar-radius\RADAR\RADAR.vbproj", "{3AB08A4E-C4FA-4571-A5D4-32BBA807C31D}"
|
||||||
EndProject
|
EndProject
|
|
@ -9,7 +9,7 @@ Imports System
|
||||||
Imports System.Net.Mail
|
Imports System.Net.Mail
|
||||||
Imports RADAR
|
Imports RADAR
|
||||||
|
|
||||||
Public Class CICRadarR
|
Public Class RDSFactor
|
||||||
|
|
||||||
Public Shared LDAPDomain As String = ""
|
Public Shared LDAPDomain As String = ""
|
||||||
Public Shared ADField As String = ""
|
Public Shared ADField As String = ""
|
|
@ -88,11 +88,11 @@
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Application.myapp</DependentUpon>
|
<DependentUpon>Application.myapp</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="CICRadarR.vb">
|
<Compile Include="RDSFactor.vb">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="CICRadarR.Designer.vb">
|
<Compile Include="RDSFactor.Designer.vb">
|
||||||
<DependentUpon>CICRadarR.vb</DependentUpon>
|
<DependentUpon>RDSFactor.vb</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||||
<Compile Include="My Project\Resources.Designer.vb">
|
<Compile Include="My Project\Resources.Designer.vb">
|
||||||
|
@ -120,8 +120,8 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="CICRadarR.resx">
|
<EmbeddedResource Include="RDSFactor.resx">
|
||||||
<DependentUpon>CICRadarR.vb</DependentUpon>
|
<DependentUpon>RDSFactor.vb</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="My Project\Resources.resx">
|
<EmbeddedResource Include="My Project\Resources.resx">
|
||||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Public Class TestService
|
Public Class TestService
|
||||||
|
|
||||||
Private Radius_Service As New CICRadarR
|
Private Radius_Service As New RDSFactor
|
||||||
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
|
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
|
||||||
btnStart.Enabled = False
|
btnStart.Enabled = False
|
||||||
Call Radius_Service.OnstartTest()
|
Call Radius_Service.OnstartTest()
|
|
@ -17,7 +17,7 @@ Public Class CitrixHandler
|
||||||
' and drop other requests silently ...
|
' and drop other requests silently ...
|
||||||
|
|
||||||
If packet.Code <> RadiusPacketCode.AccessRequest Then
|
If packet.Code <> RadiusPacketCode.AccessRequest Then
|
||||||
CICRadarR.AccessLog("Not a valid radius packet.. Drop!")
|
RDSFactor.AccessLog("Not a valid radius packet.. Drop!")
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ Public Class CitrixHandler
|
||||||
' will return Nothing.
|
' will return Nothing.
|
||||||
If username Is Nothing Then
|
If username Is Nothing Then
|
||||||
' Technically, this case is against RFC, so ... drop.
|
' Technically, this case is against RFC, so ... drop.
|
||||||
CICRadarR.AccessLog("Not a valid radius packet.. No username pressent.. Drop!")
|
RDSFactor.AccessLog("Not a valid radius packet.. No username pressent.. Drop!")
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CICRadarR.AccessLog("Processing packet for user: " & username.ToString)
|
RDSFactor.AccessLog("Processing packet for user: " & username.ToString)
|
||||||
|
|
||||||
'If packetHash.ContainsKey(username.GetString & "_" & pass.GetString) Then
|
'If packetHash.ContainsKey(username.GetString & "_" & pass.GetString) Then
|
||||||
' Exit Sub
|
' Exit Sub
|
||||||
|
@ -49,27 +49,27 @@ Public Class CitrixHandler
|
||||||
|
|
||||||
|
|
||||||
Dim existState As Boolean = packet.Attributes.AttributeExists(RadiusAttributeType.State)
|
Dim existState As Boolean = packet.Attributes.AttributeExists(RadiusAttributeType.State)
|
||||||
CICRadarR.AccessLog("Packet contains a state attribute? State=" & existState.ToString)
|
RDSFactor.AccessLog("Packet contains a state attribute? State=" & existState.ToString)
|
||||||
If existState = True Then ' Ok we have at packet with the State attribute set. Check if we can identify the authtentication packet.
|
If existState = True Then ' Ok we have at packet with the State attribute set. Check if we can identify the authtentication packet.
|
||||||
Dim state As String = packet.Attributes.GetFirstAttribute(RadiusAttributeType.State).ToString
|
Dim state As String = packet.Attributes.GetFirstAttribute(RadiusAttributeType.State).ToString
|
||||||
CICRadarR.AccessLog("Packet contains a state attribute State=" & state)
|
RDSFactor.AccessLog("Packet contains a state attribute State=" & state)
|
||||||
Dim UserDomain As String = ""
|
Dim UserDomain As String = ""
|
||||||
'lets see if user login using upd or UPN name
|
'lets see if user login using upd or UPN name
|
||||||
Dim sUserName As String = username.ToString
|
Dim sUserName As String = username.ToString
|
||||||
Dim sPassword As String = packet.UserPassword
|
Dim sPassword As String = packet.UserPassword
|
||||||
|
|
||||||
CICRadarR.AccessLog("SMSToken supplied by user: " & sUserName)
|
RDSFactor.AccessLog("SMSToken supplied by user: " & sUserName)
|
||||||
|
|
||||||
sid = ""
|
sid = ""
|
||||||
If InStr(sUserName, "@") > 0 Then 'UPN
|
If InStr(sUserName, "@") > 0 Then 'UPN
|
||||||
UserDomain = sUserName
|
UserDomain = sUserName
|
||||||
Else 'UPD
|
Else 'UPD
|
||||||
'read domain from Hashtable
|
'read domain from Hashtable
|
||||||
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName
|
UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
|
||||||
End If
|
End If
|
||||||
|
|
||||||
sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, CICRadarR.encCode)
|
sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, RDSFactor.encCode)
|
||||||
CICRadarR.AccessLog("Checking for userHash " & sid)
|
RDSFactor.AccessLog("Checking for userHash " & sid)
|
||||||
If sid = state Then
|
If sid = state Then
|
||||||
packet.AcceptAccessRequest()
|
packet.AcceptAccessRequest()
|
||||||
Else
|
Else
|
||||||
|
@ -97,15 +97,15 @@ Public Class CitrixHandler
|
||||||
UserDomain = sUserName
|
UserDomain = sUserName
|
||||||
Else 'UPD
|
Else 'UPD
|
||||||
'read domain from Hashtable
|
'read domain from Hashtable
|
||||||
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName
|
UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CICRadarR.AccessLog("User " & UserDomain & " is trying to log in ...")
|
RDSFactor.AccessLog("User " & UserDomain & " is trying to log in ...")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim dirEntry As New DirectoryEntry("LDAP://" & CICRadarR.LDAPDomain, UserDomain, sPassword)
|
Dim dirEntry As New DirectoryEntry("LDAP://" & RDSFactor.LDAPDomain, UserDomain, sPassword)
|
||||||
|
|
||||||
Dim obj As Object = dirEntry.NativeObject
|
Dim obj As Object = dirEntry.NativeObject
|
||||||
Dim search As New DirectorySearcher(dirEntry)
|
Dim search As New DirectorySearcher(dirEntry)
|
||||||
|
@ -118,17 +118,17 @@ Public Class CitrixHandler
|
||||||
'Load the Properties we need from AD
|
'Load the Properties we need from AD
|
||||||
search.PropertiesToLoad.Add("distinguishedName")
|
search.PropertiesToLoad.Add("distinguishedName")
|
||||||
'search.PropertiesToLoad.Add("primaryTelexNumber")
|
'search.PropertiesToLoad.Add("primaryTelexNumber")
|
||||||
If CICRadarR.EnableOTP = True Then
|
If RDSFactor.EnableOTP = True Then
|
||||||
If CICRadarR.EnableEmail = True Then
|
If RDSFactor.EnableEmail = True Then
|
||||||
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
search.PropertiesToLoad.Add(RDSFactor.ADMailField)
|
||||||
End If
|
End If
|
||||||
If CICRadarR.EnableSMS = True Then
|
If RDSFactor.EnableSMS = True Then
|
||||||
search.PropertiesToLoad.Add(CICRadarR.ADField)
|
search.PropertiesToLoad.Add(RDSFactor.ADField)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
' Time to find out if user entered the correct username and pasword
|
' Time to find out if user entered the correct username and pasword
|
||||||
CICRadarR.AccessLog("Trying to authenticate user agains Active Directory using te following parameters: " & "LDAPPAth: " & "LDAP://" & CICRadarR.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
|
RDSFactor.AccessLog("Trying to authenticate user agains Active Directory using te following parameters: " & "LDAPPAth: " & "LDAP://" & RDSFactor.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
|
||||||
|
|
||||||
Dim result As SearchResult = search.FindOne()
|
Dim result As SearchResult = search.FindOne()
|
||||||
'Get the setting form AD. Yes we uses the field primaryTelexNumber, for who the f... still users telex. (I bet half the people reading this code don't even know what a telex is!)
|
'Get the setting form AD. Yes we uses the field primaryTelexNumber, for who the f... still users telex. (I bet half the people reading this code don't even know what a telex is!)
|
||||||
|
@ -137,43 +137,43 @@ Public Class CitrixHandler
|
||||||
|
|
||||||
'Dim userLdap As String = "LDAP://" & LDAPPath & "/" & result.Properties("distinguishedName")(0)
|
'Dim userLdap As String = "LDAP://" & LDAPPath & "/" & result.Properties("distinguishedName")(0)
|
||||||
'Dim userEntry As New DirectoryEntry(userLdap, UserDomain, sPassword)
|
'Dim userEntry As New DirectoryEntry(userLdap, UserDomain, sPassword)
|
||||||
If CICRadarR.EnableOTP = True Then
|
If RDSFactor.EnableOTP = True Then
|
||||||
smsCode = CICRadarR.GenerateCode()
|
smsCode = RDSFactor.GenerateCode()
|
||||||
|
|
||||||
' REMEMBER to put at check for empty phone string
|
' REMEMBER to put at check for empty phone string
|
||||||
If CICRadarR.EnableEmail = True Then
|
If RDSFactor.EnableEmail = True Then
|
||||||
Try
|
Try
|
||||||
UserEmail = DirectCast(result.Properties(CICRadarR.ADMailField)(0), String)
|
UserEmail = DirectCast(result.Properties(RDSFactor.ADMailField)(0), String)
|
||||||
|
|
||||||
If UserEmail.Trim.Length = 0 Or InStr(UserEmail, "@") = 0 Then
|
If UserEmail.Trim.Length = 0 Or InStr(UserEmail, "@") = 0 Then
|
||||||
success = False
|
success = False
|
||||||
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain)
|
RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||||
Else
|
Else
|
||||||
success = True
|
success = True
|
||||||
End If
|
End If
|
||||||
Catch
|
Catch
|
||||||
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain)
|
RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||||
success = False
|
success = False
|
||||||
End Try
|
End Try
|
||||||
End If
|
End If
|
||||||
If CICRadarR.EnableSMS = True Then
|
If RDSFactor.EnableSMS = True Then
|
||||||
Try
|
Try
|
||||||
mobile = DirectCast(result.Properties(CICRadarR.ADField)(0), String)
|
mobile = DirectCast(result.Properties(RDSFactor.ADField)(0), String)
|
||||||
mobile = Replace(mobile, "+", "")
|
mobile = Replace(mobile, "+", "")
|
||||||
If mobile.Trim.Length = 0 Then
|
If mobile.Trim.Length = 0 Then
|
||||||
success = False
|
success = False
|
||||||
CICRadarR.AccessLog("Unable to find correct phone number for user " & UserDomain)
|
RDSFactor.AccessLog("Unable to find correct phone number for user " & UserDomain)
|
||||||
Else
|
Else
|
||||||
success = True
|
success = True
|
||||||
End If
|
End If
|
||||||
Catch
|
Catch
|
||||||
CICRadarR.AccessLog("Unable to find correct phone number for user " & UserDomain)
|
RDSFactor.AccessLog("Unable to find correct phone number for user " & UserDomain)
|
||||||
success = False
|
success = False
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
sid = EncDec.Encrypt(UserDomain & "_" & smsCode, CICRadarR.encCode) 'generate unique code
|
sid = EncDec.Encrypt(UserDomain & "_" & smsCode, RDSFactor.encCode) 'generate unique code
|
||||||
End If
|
End If
|
||||||
' sid = UserDomain & "_" & smsCode
|
' sid = UserDomain & "_" & smsCode
|
||||||
'userEntry.Properties("primaryTelexNumber").Value = aCode(0) & "/" & smsCode & "/" & aCode(2) & "/" & aCode(3)
|
'userEntry.Properties("primaryTelexNumber").Value = aCode(0) & "/" & smsCode & "/" & aCode(2) & "/" & aCode(3)
|
||||||
|
@ -199,7 +199,7 @@ Public Class CitrixHandler
|
||||||
success = False
|
success = False
|
||||||
End If
|
End If
|
||||||
Catch
|
Catch
|
||||||
CICRadarR.AccessLog("Failed to authenticate user agains Active Directory using the following parameters: " & "LDAPPAth: " & "LDAP://" & CICRadarR.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
|
RDSFactor.AccessLog("Failed to authenticate user agains Active Directory using the following parameters: " & "LDAPPAth: " & "LDAP://" & RDSFactor.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
|
||||||
success = False
|
success = False
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
|
@ -207,8 +207,8 @@ Public Class CitrixHandler
|
||||||
Dim attributes As New RADIUSAttributes
|
Dim attributes As New RADIUSAttributes
|
||||||
If success Then ' Yay! Someone guess the password ...
|
If success Then ' Yay! Someone guess the password ...
|
||||||
|
|
||||||
CICRadarR.AccessLog("User " & UserDomain & " authenticated agains Active Directory")
|
RDSFactor.AccessLog("User " & UserDomain & " authenticated agains Active Directory")
|
||||||
If CICRadarR.EnableOTP = True Then
|
If RDSFactor.EnableOTP = True Then
|
||||||
Dim attr As New RADIUSAttribute(RadiusAttributeType.ReplyMessage, "SMS Token")
|
Dim attr As New RADIUSAttribute(RadiusAttributeType.ReplyMessage, "SMS Token")
|
||||||
attributes.Add(attr)
|
attributes.Add(attr)
|
||||||
Dim state As New RADIUSAttribute(RadiusAttributeType.State, sid)
|
Dim state As New RADIUSAttribute(RadiusAttributeType.State, sid)
|
||||||
|
@ -219,22 +219,22 @@ Public Class CitrixHandler
|
||||||
packet.Identifier, attributes, _
|
packet.Identifier, attributes, _
|
||||||
packet.EndPoint), _
|
packet.EndPoint), _
|
||||||
packet.Authenticator)
|
packet.Authenticator)
|
||||||
If CICRadarR.EnableSMS = True Then
|
If RDSFactor.EnableSMS = True Then
|
||||||
CICRadarR.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile)
|
RDSFactor.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile)
|
||||||
Call CICRadarR.SendSMS(mobile, smsCode)
|
Call RDSFactor.SendSMS(mobile, smsCode)
|
||||||
End If
|
End If
|
||||||
If CICRadarR.EnableEmail = True Then
|
If RDSFactor.EnableEmail = True Then
|
||||||
CICRadarR.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail)
|
RDSFactor.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail)
|
||||||
Call CICRadarR.SendEmail(UserEmail, smsCode)
|
Call RDSFactor.SendEmail(UserEmail, smsCode)
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
CICRadarR.AccessLog("One time Password not enabled, so we let the user in")
|
RDSFactor.AccessLog("One time Password not enabled, so we let the user in")
|
||||||
packet.AcceptAccessRequest()
|
packet.AcceptAccessRequest()
|
||||||
End If
|
End If
|
||||||
' packetHash.Remove(username.GetString & "_" & pass.GetString)
|
' packetHash.Remove(username.GetString & "_" & pass.GetString)
|
||||||
Else ' Wrong username / password ...
|
Else ' Wrong username / password ...
|
||||||
|
|
||||||
CICRadarR.AccessLog("User " & UserDomain & " failed to authenticate against Active Directory")
|
RDSFactor.AccessLog("User " & UserDomain & " failed to authenticate against Active Directory")
|
||||||
Dim pk As New RADIUSPacket(RadiusPacketCode.AccessReject, packet.Identifier, Nothing, packet.EndPoint)
|
Dim pk As New RADIUSPacket(RadiusPacketCode.AccessReject, packet.Identifier, Nothing, packet.EndPoint)
|
||||||
server.SendAsResponse(pk, packet.Authenticator)
|
server.SendAsResponse(pk, packet.Authenticator)
|
||||||
' FYI ... if no additional attributes need to be added
|
' FYI ... if no additional attributes need to be added
|
|
@ -75,7 +75,7 @@ Public Class RDSHandler
|
||||||
' NOTE: Requests contain the session GUID in the password attribute
|
' NOTE: Requests contain the session GUID in the password attribute
|
||||||
' of the packet.
|
' of the packet.
|
||||||
Public Sub ProcessAppLaunchRequest()
|
Public Sub ProcessAppLaunchRequest()
|
||||||
CICRadarR.AccessLog("ProcessAppLaunchRequest")
|
RDSFactor.AccessLog("ProcessAppLaunchRequest")
|
||||||
|
|
||||||
' When the packet is an AppLaunchRequest the password attribute contains the session id!
|
' When the packet is an AppLaunchRequest the password attribute contains the session id!
|
||||||
Dim packetSessionId = mPassword
|
Dim packetSessionId = mPassword
|
||||||
|
@ -83,15 +83,15 @@ Public Class RDSHandler
|
||||||
Dim sessionTimestamp = sessionTimestamps(mUsername)
|
Dim sessionTimestamp = sessionTimestamps(mUsername)
|
||||||
|
|
||||||
If storedSessionId = Nothing Or sessionTimestamp = Nothing Then
|
If storedSessionId = Nothing Or sessionTimestamp = Nothing Then
|
||||||
CICRadarR.AccessLog("User has no session. MUST re-authenticate!")
|
RDSFactor.AccessLog("User has no session. MUST re-authenticate!")
|
||||||
mPacket.RejectAccessRequest()
|
mPacket.RejectAccessRequest()
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If packetSessionId = storedSessionId Then
|
If packetSessionId = storedSessionId Then
|
||||||
Dim minsSinceLastActivity = DateDiff(DateInterval.Minute, sessionTimestamp, Now)
|
Dim minsSinceLastActivity = DateDiff(DateInterval.Minute, sessionTimestamp, Now)
|
||||||
If minsSinceLastActivity < CICRadarR.SessionTimeOut Then
|
If minsSinceLastActivity < RDSFactor.SessionTimeOut Then
|
||||||
CICRadarR.AccessLog("Opening window for: " & mUsername)
|
RDSFactor.AccessLog("Opening window for: " & mUsername)
|
||||||
' Pro-long session
|
' Pro-long session
|
||||||
sessionTimestamps(storedSessionId) = Now
|
sessionTimestamps(storedSessionId) = Now
|
||||||
' Open launch window
|
' Open launch window
|
||||||
|
@ -99,12 +99,12 @@ Public Class RDSHandler
|
||||||
mPacket.AcceptAccessRequest()
|
mPacket.AcceptAccessRequest()
|
||||||
Exit Sub
|
Exit Sub
|
||||||
Else
|
Else
|
||||||
CICRadarR.AccessLog("Session timed out -- User MUST re-authenticate")
|
RDSFactor.AccessLog("Session timed out -- User MUST re-authenticate")
|
||||||
userSessions.Remove(mUsername)
|
userSessions.Remove(mUsername)
|
||||||
sessionTimestamps.Remove(mUsername)
|
sessionTimestamps.Remove(mUsername)
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
CICRadarR.AccessLog("Stored session id didn't match packet session id!")
|
RDSFactor.AccessLog("Stored session id didn't match packet session id!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
mPacket.RejectAccessRequest()
|
mPacket.RejectAccessRequest()
|
||||||
|
@ -122,14 +122,14 @@ Public Class RDSHandler
|
||||||
' TODO: Fix race-condition RD Web vs. Gateway. Don't start RDP client in RD Web
|
' TODO: Fix race-condition RD Web vs. Gateway. Don't start RDP client in RD Web
|
||||||
' before ensuring App Launch request was successful
|
' before ensuring App Launch request was successful
|
||||||
Public Sub ProcessGatewayRequest()
|
Public Sub ProcessGatewayRequest()
|
||||||
CICRadarR.AccessLog("Gateway Request for user: " & mUsername)
|
RDSFactor.AccessLog("Gateway Request for user: " & mUsername)
|
||||||
|
|
||||||
Dim sessionId = userSessions(mUsername)
|
Dim sessionId = userSessions(mUsername)
|
||||||
Dim launchTimestamp = userLaunchTimestamps(mUsername)
|
Dim launchTimestamp = userLaunchTimestamps(mUsername)
|
||||||
Dim attributes As New RADIUSAttributes
|
Dim attributes As New RADIUSAttributes
|
||||||
|
|
||||||
If sessionId = Nothing Or launchTimestamp = Nothing Then
|
If sessionId = Nothing Or launchTimestamp = Nothing Then
|
||||||
CICRadarR.AccessLog("User's has no launch window. User must re-authenticate")
|
RDSFactor.AccessLog("User's has no launch window. User must re-authenticate")
|
||||||
mPacket.RejectAccessRequest()
|
mPacket.RejectAccessRequest()
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
@ -141,11 +141,11 @@ Public Class RDSHandler
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim secondsSinceLaunch = DateDiff(DateInterval.Second, launchTimestamp, Now)
|
Dim secondsSinceLaunch = DateDiff(DateInterval.Second, launchTimestamp, Now)
|
||||||
If secondsSinceLaunch < CICRadarR.LaunchTimeOut Then
|
If secondsSinceLaunch < RDSFactor.LaunchTimeOut Then
|
||||||
CICRadarR.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window")
|
RDSFactor.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window")
|
||||||
mPacket.AcceptAccessRequest(attributes)
|
mPacket.AcceptAccessRequest(attributes)
|
||||||
Else
|
Else
|
||||||
CICRadarR.AccessLog("Launch window has closed!")
|
RDSFactor.AccessLog("Launch window has closed!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' close window
|
' close window
|
||||||
|
@ -160,24 +160,24 @@ Public Class RDSHandler
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CICRadarR.AccessLog("ProcessAccessRequest")
|
RDSFactor.AccessLog("ProcessAccessRequest")
|
||||||
Try
|
Try
|
||||||
Dim ldapResult = Authenticate()
|
Dim ldapResult = Authenticate()
|
||||||
|
|
||||||
If CICRadarR.EnableOTP Then
|
If RDSFactor.EnableOTP Then
|
||||||
TwoFactorChallenge()
|
TwoFactorChallenge()
|
||||||
Exit Sub
|
Exit Sub
|
||||||
Else
|
Else
|
||||||
Accept()
|
Accept()
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
CICRadarR.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message)
|
RDSFactor.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message)
|
||||||
mPacket.RejectAccessRequest()
|
mPacket.RejectAccessRequest()
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Accept()
|
Private Sub Accept()
|
||||||
CICRadarR.AccessLog("Accept")
|
RDSFactor.AccessLog("Accept")
|
||||||
Dim sGUID As String = System.Guid.NewGuid.ToString()
|
Dim sGUID As String = System.Guid.NewGuid.ToString()
|
||||||
userSessions(mUsername) = sGUID
|
userSessions(mUsername) = sGUID
|
||||||
sessionTimestamps(mUsername) = Now
|
sessionTimestamps(mUsername) = Now
|
||||||
|
@ -190,13 +190,13 @@ Public Class RDSHandler
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub ProcessChallengeResponse()
|
Private Sub ProcessChallengeResponse()
|
||||||
CICRadarR.AccessLog("ProcessChallengeResponse")
|
RDSFactor.AccessLog("ProcessChallengeResponse")
|
||||||
|
|
||||||
' When the packet is an Challange-Response the password attr. contains the token
|
' When the packet is an Challange-Response the password attr. contains the token
|
||||||
Dim challangeCode = mPassword
|
Dim challangeCode = mPassword
|
||||||
Dim state = mPacket.Attributes.GetFirstAttribute(RadiusAttributeType.State)
|
Dim state = mPacket.Attributes.GetFirstAttribute(RadiusAttributeType.State)
|
||||||
|
|
||||||
Dim sid = EncDec.Encrypt(mUsername & "_" & challangeCode, CICRadarR.encCode)
|
Dim sid = EncDec.Encrypt(mUsername & "_" & challangeCode, RDSFactor.encCode)
|
||||||
If sid = state.ToString Then
|
If sid = state.ToString Then
|
||||||
Accept()
|
Accept()
|
||||||
Else
|
Else
|
||||||
|
@ -205,19 +205,19 @@ Public Class RDSHandler
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub TwoFactorChallenge()
|
Private Sub TwoFactorChallenge()
|
||||||
Dim code = CICRadarR.GenerateCode
|
Dim code = RDSFactor.GenerateCode
|
||||||
Dim sid = EncDec.Encrypt(mUsername & "_" & code, CICRadarR.encCode) 'generate unique code
|
Dim sid = EncDec.Encrypt(mUsername & "_" & code, RDSFactor.encCode) 'generate unique code
|
||||||
CICRadarR.AccessLog("Access Challange Code: " & code)
|
RDSFactor.AccessLog("Access Challange Code: " & code)
|
||||||
|
|
||||||
userSidTokens(mUsername) = sid
|
userSidTokens(mUsername) = sid
|
||||||
tokenTimestamps(mUsername) = Now
|
tokenTimestamps(mUsername) = Now
|
||||||
|
|
||||||
If mUseSMSFactor Then
|
If mUseSMSFactor Then
|
||||||
CICRadarR.AccessLog("TODO: Send SMS")
|
RDSFactor.AccessLog("TODO: Send SMS")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If mUseEmailFactor Then
|
If mUseEmailFactor Then
|
||||||
CICRadarR.AccessLog("TODO: Send Email")
|
RDSFactor.AccessLog("TODO: Send Email")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim attributes As New RADIUSAttributes
|
Dim attributes As New RADIUSAttributes
|
||||||
|
@ -233,9 +233,9 @@ Public Class RDSHandler
|
||||||
|
|
||||||
Private Function Authenticate() As System.DirectoryServices.SearchResult
|
Private Function Authenticate() As System.DirectoryServices.SearchResult
|
||||||
Dim password As String = mPacket.UserPassword
|
Dim password As String = mPacket.UserPassword
|
||||||
Dim ldapDomain As String = CICRadarR.LDAPDomain
|
Dim ldapDomain As String = RDSFactor.LDAPDomain
|
||||||
|
|
||||||
CICRadarR.AccessLog("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & mUsername)
|
RDSFactor.AccessLog("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & mUsername)
|
||||||
Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, mUsername, password)
|
Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, mUsername, password)
|
||||||
|
|
||||||
Dim obj As Object = dirEntry.NativeObject
|
Dim obj As Object = dirEntry.NativeObject
|
||||||
|
@ -248,15 +248,15 @@ Public Class RDSHandler
|
||||||
End If
|
End If
|
||||||
|
|
||||||
search.PropertiesToLoad.Add("distinguishedName")
|
search.PropertiesToLoad.Add("distinguishedName")
|
||||||
If CICRadarR.EnableOTP = True Then
|
If RDSFactor.EnableOTP = True Then
|
||||||
search.PropertiesToLoad.Add(CICRadarR.ADField)
|
search.PropertiesToLoad.Add(RDSFactor.ADField)
|
||||||
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
search.PropertiesToLoad.Add(RDSFactor.ADMailField)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim result = search.FindOne()
|
Dim result = search.FindOne()
|
||||||
|
|
||||||
If IsDBNull(result) Then
|
If IsDBNull(result) Then
|
||||||
CICRadarR.AccessLog("Failed to authenticate with Active Directory")
|
RDSFactor.AccessLog("Failed to authenticate with Active Directory")
|
||||||
Throw New MissingUser
|
Throw New MissingUser
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
@ -264,19 +264,19 @@ Public Class RDSHandler
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function LdapGetNumber(result As SearchResult) As String
|
Private Function LdapGetNumber(result As SearchResult) As String
|
||||||
Dim mobile = result.Properties(CICRadarR.ADField)(0)
|
Dim mobile = result.Properties(RDSFactor.ADField)(0)
|
||||||
mobile = Replace(mobile, "+", "")
|
mobile = Replace(mobile, "+", "")
|
||||||
If mobile.Trim.Length = 0 Then
|
If mobile.Trim.Length = 0 Then
|
||||||
CICRadarR.AccessLog("Unable to find correct phone number for user " & mUsername)
|
RDSFactor.AccessLog("Unable to find correct phone number for user " & mUsername)
|
||||||
End If
|
End If
|
||||||
Return mobile
|
Return mobile
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function LdapGetEmail(result As SearchResult) As String
|
Private Function LdapGetEmail(result As SearchResult) As String
|
||||||
Dim email = result.Properties(CICRadarR.ADMailField)(0)
|
Dim email = result.Properties(RDSFactor.ADMailField)(0)
|
||||||
|
|
||||||
If InStr(email, "@") = 0 Then
|
If InStr(email, "@") = 0 Then
|
||||||
CICRadarR.AccessLog("Unable to find correct email for user " & mUsername)
|
RDSFactor.AccessLog("Unable to find correct email for user " & mUsername)
|
||||||
End If
|
End If
|
||||||
Return email
|
Return email
|
||||||
End Function
|
End Function
|
Loading…
Add table
Add a link
Reference in a new issue