VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Security DLL Posted by Martok867 on 5 Aug 2012 at 9:45 PM
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 = "\\appserver\AppLogs\app.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)

FileClose(1)

Else
Err.Number = 1
Call ErrorCodeHandle()
End If
Else
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 Support@company.com for assistance, this application wil now close.")
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 Support@comapany.com for assistance")
Close()


End Select
End Sub
End Class



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.