Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > File creator info


Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2007, 03:24 AM
Bagera Bagera is offline
Freshman
 
Join Date: Sep 2004
Posts: 33
Default File creator info


Is it possible in any way to get the usernname or computername that created or modified a file?

Can i get if from the file properties or can i get it from the filesystem?

In any way is it possible?

Thanks!

Last edited by Bagera; 05-15-2007 at 03:25 AM. Reason: Forgot the notification again
Reply With Quote
  #2  
Old 05-15-2007, 07:18 AM
Bagera Bagera is offline
Freshman
 
Join Date: Sep 2004
Posts: 33
Default

Well i have this now and it works fine with some files but on most the files from varius apps i get
administrators for name
and Built in for domain.

ret = GetNamedSecurityInfo(Path, 1, 1, OwnerSid, Nothing, Nothing, Nothing, SD)
LookupAccountSid(MachineName, OwnerSid, name, name_len, domain_name, domain_len, peUse)

Anyone have a clue, is there another way?
Reply With Quote
  #3  
Old 05-15-2007, 08:10 AM
Bagera Bagera is offline
Freshman
 
Join Date: Sep 2004
Posts: 33
Default

Aha, after some poking around i am starting to at least know what im looking for.
Its not the owner of a file im interestad of, its the creator or machine the file was created on and that even if the file has been saved directly to a network drive.
Reply With Quote
  #4  
Old 05-15-2007, 11:41 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

The System.IO.FileInfo class will allow you to get properties of a file, such as last write date, size, other stuff - - but does not give modified by or author properties, nor the source machine/computer name

Security on the file system in .Net is accessed via the FileInfo.GetAccessControl method which returns a System.Security.AccessControl.FileSecurity object.

Here is an article on the subject which you can review:

http://aspalliance.com/1047_Working_...s_Control_List
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #5  
Old 05-16-2007, 02:01 AM
Bagera Bagera is offline
Freshman
 
Join Date: Sep 2004
Posts: 33
Default

Thanks!

But i think i have to get a new strategy, dosnt seam to be possible to get the creator of a file, that information does not exist in a file, only if
something or someone has set the author property.

Correct me if im wrong (I hope i am)
Reply With Quote
  #6  
Old 05-16-2007, 08:53 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

You aren't going to be able to probe any single .Net System.IO class for this information. You need to roll into the NTFS and Active Directory or whatever security model is in place. And even then, you aren't going to find a straight forward way to get a friendly user name and machine name for every file on a given network.

Now, you can get IP addresses of machines using the .Net DNS namespace and you can even get machine names and user names out of the .Net Environment namespace. But the problem is you want to pull this information out of the NTFS or basically your application isn't grabbing this information from a user of THAT application - - but you want to "query" for this information given a set of pre-created files.

Unfortunately trying pull this information out of the NTFS is something I really can't help you with .
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #7  
Old 05-16-2007, 09:08 AM
Bagera Bagera is offline
Freshman
 
Join Date: Sep 2004
Posts: 33
Default

Thank you anyway!

I think i make a sniffer instead, it seams like a simpler way, then i can get the file creation and the ip and all that.

Is it a good idea to do this in vb or is c++ better for stability and performance?
Reply With Quote
  #8  
Old 05-16-2007, 09:14 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

My response to questions like that is always "choose the best language AND best design for the current problem". You could create a C++ dll and reference it within your .Net application. You could also write it in C# and reference that compiled .Net assembly within your VB.net project. Regarding the different languages provided in .Net the CLR allows us to use any combination or languages within a single solution.

Would you NEED to write this in C++, probably not. Could you write it in VB.net, without knowing exactly what you are going to do, I'd say most likely you can.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #9  
Old 10-30-2008, 04:33 AM
TaylorBasford TaylorBasford is offline
Newcomer
 
Join Date: Oct 2008
Location: hawaii
Posts: 1
Default

Thanks!!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->