Security DLL

Hi All,
I am writing several small applications and I am looking to serure them to our network.
I can check that the running compuiter is on the company domain and that it can see the application logfile. If either of these fail it will display a message and close the application. This works fine if the code in in the app but I want to use the same code for several apps.
How do I do this in a DLL, identify the calling application and on error close the calling app?

I'm sure there is a simply way to do this???

Private Sub AccessCheck()

UserName = System.Security.Principal.WindowsIdentity.GetCurrent.Name
ComputerName = Environment.MachineName
DomainName = Environment.UserDomainName
Accesstime = Date.Now
LogFile = "\appserverAppLogsapp.log"
If File.Exists(LogFile) Then

If DomainName = "CompanyDomain" Then
FileOpen(1, LogFile, OpenMode.Append, OpenAccess.Write, OpenShare.LockWrite)
WriteLine(1, Accesstime, UserName, ComputerName, DomainName)


Err.Number = 1
Call ErrorCodeHandle()
End If
Err.Number = 2
Call ErrorCodeHandle()
End If

End Sub

Private Sub ErrorCodeHandle()
Select Case Err.Number 'Evaluate the error number.
Case 1 'Incorrect domain
MsgBox("You are not Authorised to use this application...........")
MsgBox("Please contact [email protected] for assistance, this application wil now close.")

Case 2 'Unable to locate log file
MsgBox("Unable to locate Application log file, Please ensure you are connected to the correct Domain")
MsgBox("Please contact [email protected] for assistance")

End Select
End Sub
End Class
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!