Log user

I want to be able to log the persons that have accessed a vbp, anyone know of code or a site where i could get/do this maybe an ADD-IN?

Thanks in advance
bja1Asked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
To set security on projects:
-Enter in "VSS admin".
-From the "Tools" menu, choose "Options...".
-On the "Project Security" tab, check the "Enable project security" and click OK.
-From the "Tools" menu, choose "Rights by project..." and select the rights you want for each user.

To set read-only user's:
-Enter in "VSS admin".
-Select the user in the list.
-From the "Users" menu, choose the "Edit user..." option.
-Check the "Read only" check box.
0
 
adityauCommented:
Please be specific. Whom do you wan to log? The machine name or do you want to ask a login box and log that person's name?
0
 
bja1Author Commented:
network username
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
bja1Author Commented:
Ok. I have a project on the network drive that is accessible by all. Now, things are being changed without my consent. Everytime the project is opened I want to write to a text file the nt username or even the machinename of the person and the date/time. This way when people change my work I can figure out who it is.
Sorry for the confusion.
Thanks
0
 
deightonCommented:
Private Sub Form_Load()

    Open "c:\log.txt" For Append As #1
   
        Print #1, "User = " & UserName & _
        " : Machine Name = " & _
        ComputerName & " at " & _
        Format(Now, "short time") & " " _
        & Format(Date, "short date")
   
    Close #1

End Sub

Then in a .bas module

Attribute VB_Name = "Module1"
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long


Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOW = 5

Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long

Public Function VersioneWindows() As String
    Dim myOS As OSVERSIONINFO

    myOS.dwOSVersionInfoSize = Len(myOS)
    GetVersionEx myOS
    If myOS.dwMajorVersion = 4 Then
        If myOS.dwPlatformId = VER_PLATFORM_WIN32_NT Then
            VersioneWindows = "Windows NT version: "
        ElseIf myOS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
            VersioneWindows = "Windows 95 version: "
        End If
    Else
        VersioneWindows = "Windows version: "
    End If
    VersioneWindows = VersioneWindows & myOS.dwMajorVersion & "." & myOS.dwMinorVersion
End Function
Public Sub ApplicationBar(Visible As Boolean)
    Dim hWnd As Long

    hWnd = FindWindow("Shell_TrayWnd", "")
    If Visible Then
        ShowWindow hWnd, SW_SHOW
    Else
        ShowWindow hWnd, SW_HIDE
    End If
    EnableWindow hWnd, Visible
End Sub

Public Sub Desktop(Visible As Boolean)
    Dim hWnd As Long

    hWnd = FindWindow("Progman", "Program Manager")
    If Visible Then
        ShowWindow hWnd, SW_SHOW
    Else
        ShowWindow hWnd, SW_HIDE
    End If
    EnableWindow hWnd, Visible
End Sub
Public Function UserName() As String
    Dim cn As String
    Dim ls As Long
    Dim res As Long

    cn = String(1024, 0)
    ls = 1024
    res = GetUserName(cn, ls)
    If res <> 0 Then
        UserName = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
    Else
        UserName = ""
    End If
End Function


Public Function fSetComputerName(Name As String) As Boolean
    Dim res As Long

    res = SetComputerName(Name)
    SetComputerName = (res <> 0)
End Function
Public Function ComputerName() As String
    Dim cn As String
    Dim ls As Long
    Dim res As Long

    cn = String(1024, 0)
    ls = 1024
    res = GetComputerName(cn, ls)
    If res <> 0 Then
        ComputerName = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
    Else
        ComputerName = ""
    End If
End Function
0
 
bja1Author Commented:
Maybe I'm not very clear with the way I explained the question.  I have a project on a network drive, anyone that has access to this drive (50+) working on a machine with VB installed can open and change the .vbp file.

What i want to know is, is there a way to log the username/machinename and datetime when the vbp is opened, not ran as the person may not run the app just change some code....any ideas
0
 
SLECommented:
MS Visual SourceSafe...
0
 
bja1Author Commented:
ok you have me as I know sweet FA about VSS i know it keeps the last version of the code but not a log of who has accessed the code.
0
 
Éric MoreauSenior .Net ConsultantCommented:
With VSS, you can restrict some users to read-only and you can even hide projects to users.
0
 
bja1Author Commented:
Is it hard to set up (believe me the only thing I've touched with VSS is the clicking the no on the "Add to Visaul Source" when opening a new project.
0
 
MTroutwineCommented:
If this is on a network share and the share is on an NTFS partition while not enable 'Auditing' on the share.   Since the share is most likely secured to only allow access to it from certain groups and/or users you could easily setup 'Auditing' to track the following items:

Read
Write
Execute
Delete
Change Permissions
Take Ownership

You will need to have Full Control of the share in order to set this up, but it would be the most effective way to do what you are wanting to do.
0
All Courses

From novice to tech pro — start learning today.