Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Security DLL

Martok867Martok867 Posts: 2Member
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 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 for assistance")

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