mirror of
https://github.com/jakobadam/RDSFactor.git
synced 2025-07-22 17:45:54 +02:00
Notify if shared RADIUS secret is missing
This commit is contained in:
parent
dccef64f40
commit
4a1e1471f6
6 changed files with 22 additions and 6 deletions
|
@ -78,7 +78,8 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Conversion.vb" />
|
<Compile Include="Conversion.vb" />
|
||||||
<Compile Include="exceptions\MissingUserException.vb" />
|
<Compile Include="exceptions\MissingRadiusSecret.vb" />
|
||||||
|
<Compile Include="exceptions\MissingUser.vb" />
|
||||||
<Compile Include="handlers\RDSHandler.vb" />
|
<Compile Include="handlers\RDSHandler.vb" />
|
||||||
<Compile Include="VendorSpefic.vb" />
|
<Compile Include="VendorSpefic.vb" />
|
||||||
<Compile Include="Crypto.vb" />
|
<Compile Include="Crypto.vb" />
|
||||||
|
|
|
@ -67,6 +67,11 @@ Public Class RADIUSServer
|
||||||
Dim hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create
|
Dim hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create
|
||||||
Dim hash() As Byte = {}
|
Dim hash() As Byte = {}
|
||||||
Dim secret As String = mSecrets.GetSharedSecret(packet.EndPoint.Address.ToString)
|
Dim secret As String = mSecrets.GetSharedSecret(packet.EndPoint.Address.ToString)
|
||||||
|
|
||||||
|
If secret = Nothing Then
|
||||||
|
Throw New MissingRadiusSecret(packet.EndPoint.Address.ToString)
|
||||||
|
End If
|
||||||
|
|
||||||
Array.Resize(hash, data.Length + secret.Length)
|
Array.Resize(hash, data.Length + secret.Length)
|
||||||
data.CopyTo(hash, 0)
|
data.CopyTo(hash, 0)
|
||||||
ConvertToBytes(secret).CopyTo(hash, data.Length)
|
ConvertToBytes(secret).CopyTo(hash, data.Length)
|
||||||
|
|
9
CICRadarR/exceptions/MissingRadiusSecret.vb
Normal file
9
CICRadarR/exceptions/MissingRadiusSecret.vb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Public Class MissingRadiusSecret
|
||||||
|
|
||||||
|
Inherits Exception
|
||||||
|
|
||||||
|
Public Sub New(ByVal ip As String)
|
||||||
|
MyBase.New("No shared secret for ip: " & ip & ". This MUST be inserted in the config file.")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
3
CICRadarR/exceptions/MissingUser.vb
Normal file
3
CICRadarR/exceptions/MissingUser.vb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Public Class MissingUser
|
||||||
|
Inherits Exception
|
||||||
|
End Class
|
|
@ -1,3 +0,0 @@
|
||||||
Public Class MissingUserException
|
|
||||||
Inherits Exception
|
|
||||||
End Class
|
|
|
@ -122,6 +122,7 @@ Public Class RDSHandler
|
||||||
Accept()
|
Accept()
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
Console.WriteLine("Authentication failed. Sending reject.")
|
||||||
mPacket.RejectAccessRequest()
|
mPacket.RejectAccessRequest()
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
@ -179,6 +180,7 @@ Public Class RDSHandler
|
||||||
Dim password As String = mPacket.UserPassword
|
Dim password As String = mPacket.UserPassword
|
||||||
Dim ldapDomain As String = CICRadarR.LDAPDomain
|
Dim ldapDomain As String = CICRadarR.LDAPDomain
|
||||||
|
|
||||||
|
Console.WriteLine("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & packetUsername)
|
||||||
Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, packetUsername, password)
|
Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, packetUsername, password)
|
||||||
|
|
||||||
Dim obj As Object = dirEntry.NativeObject
|
Dim obj As Object = dirEntry.NativeObject
|
||||||
|
@ -196,12 +198,11 @@ Public Class RDSHandler
|
||||||
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Console.WriteLine("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & packetUsername)
|
|
||||||
Dim result = search.FindOne()
|
Dim result = search.FindOne()
|
||||||
|
|
||||||
If IsDBNull(result) Then
|
If IsDBNull(result) Then
|
||||||
Console.WriteLine("Failed to authenticate with Active Directory")
|
Console.WriteLine("Failed to authenticate with Active Directory")
|
||||||
Throw New MissingUserException
|
Throw New MissingUser
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return result
|
Return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue