473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Change file summary (title, author, etc.)

Hello,

I am having some sort of security issue with my code. When I change a
file's title in a Windows or console app, I have no problems. (I am using
Microsoft's article & DsoFile.dll:
http://support.microsoft.com/default...b;en-us;224351)

When I run it in ASP.NET, I get a "file not found" exception, even though
the file does exist.

Here is what I have already tried within ASP.NET:
1. Launch the code in a console app in a separate process.
2. Launch the code as a web service...didn't think this would work since
it's under IIS's jurisdiction as well, but tried anyway.
3. Both of the above two options while impersonating an admin account.
4. Steps 1 and 2 after fully trusting the assemblies (meaning every assembly
in my solution).

Here is my code:

Dim oSummProps As DSOFile.SummaryProperties
Dim oCustProp As DSOFile.CustomProperty
Dim sFile, sTmp As String
Dim m_oDocument As DSOFile.OleDocumentPropertiesClass

m_oDocument = New DSOFile.OleDocumentPropertiesClass
' Note: fileName is just a local file...in this case, c:\test.txt.
m_oDocument.Open(fileName, False, _
DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIf NoWriteAccess)

If Not m_oDocument.IsReadOnly Then
oSummProps = m_oDocument.SummaryProperties
oSummProps.Title = myNewTitle
m_oDocument.Save()
End If
m_oDocument.Close()
m_oDocument = Nothing

Does anybody know what to do here?

Thank you!

Eric

Nov 19 '05 #1
4 4105
Likely permissions. See under whihc account runs your app and give this
account the appropriate rights or use another directory...

A tool such as filemon from www.sysinternals.com may help to diagnose file
access problmes in case your configuration should work but still fails...

--
Patrice

"Eric" <Er**@discussions.microsoft.com> a écrit dans le message de
news:33**********************************@microsof t.com...
Hello,

I am having some sort of security issue with my code. When I change a
file's title in a Windows or console app, I have no problems. (I am using
Microsoft's article & DsoFile.dll:
http://support.microsoft.com/default...b;en-us;224351)

When I run it in ASP.NET, I get a "file not found" exception, even though
the file does exist.

Here is what I have already tried within ASP.NET:
1. Launch the code in a console app in a separate process.
2. Launch the code as a web service...didn't think this would work since
it's under IIS's jurisdiction as well, but tried anyway.
3. Both of the above two options while impersonating an admin account.
4. Steps 1 and 2 after fully trusting the assemblies (meaning every assembly in my solution).

Here is my code:

Dim oSummProps As DSOFile.SummaryProperties
Dim oCustProp As DSOFile.CustomProperty
Dim sFile, sTmp As String
Dim m_oDocument As DSOFile.OleDocumentPropertiesClass

m_oDocument = New DSOFile.OleDocumentPropertiesClass
' Note: fileName is just a local file...in this case, c:\test.txt.
m_oDocument.Open(fileName, False, _
DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIf NoWriteAccess)

If Not m_oDocument.IsReadOnly Then
oSummProps = m_oDocument.SummaryProperties
oSummProps.Title = myNewTitle
m_oDocument.Save()
End If
m_oDocument.Close()
m_oDocument = Nothing

Does anybody know what to do here?

Thank you!

Eric

Nov 19 '05 #2
On Tue, 11 Oct 2005 05:46:02 -0700, "Eric" <Er**@discussions.microsoft.com> wrote:

¤ Hello,
¤
¤ I am having some sort of security issue with my code. When I change a
¤ file's title in a Windows or console app, I have no problems. (I am using
¤ Microsoft's article & DsoFile.dll:
¤ http://support.microsoft.com/default...b;en-us;224351)
¤
¤ When I run it in ASP.NET, I get a "file not found" exception, even though
¤ the file does exist.
¤
¤ Here is what I have already tried within ASP.NET:
¤ 1. Launch the code in a console app in a separate process.
¤ 2. Launch the code as a web service...didn't think this would work since
¤ it's under IIS's jurisdiction as well, but tried anyway.
¤ 3. Both of the above two options while impersonating an admin account.
¤ 4. Steps 1 and 2 after fully trusting the assemblies (meaning every assembly
¤ in my solution).
¤
¤ Here is my code:
¤
¤ Dim oSummProps As DSOFile.SummaryProperties
¤ Dim oCustProp As DSOFile.CustomProperty
¤ Dim sFile, sTmp As String
¤ Dim m_oDocument As DSOFile.OleDocumentPropertiesClass
¤
¤ m_oDocument = New DSOFile.OleDocumentPropertiesClass
¤ ' Note: fileName is just a local file...in this case, c:\test.txt.
¤ m_oDocument.Open(fileName, False, _
¤ DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIf NoWriteAccess)
¤
¤ If Not m_oDocument.IsReadOnly Then
¤ oSummProps = m_oDocument.SummaryProperties
¤ oSummProps.Title = myNewTitle
¤ m_oDocument.Save()
¤ End If
¤ m_oDocument.Close()
¤ m_oDocument = Nothing
¤
¤ Does anybody know what to do here?

I would agree that there is a permissions problem. It isn't clear though where these files are
located or how you have implemented impersonation in your web application.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #3
Thank you for your replies, Patrice and Paul.

I think you two nudged me a little in the right direction...not quite there
yet, but close. I explicitly set the NTFS permissions on the directory to
allow the ASPNET account full access. Now, instead of the "file not found"
exception, I get "System.UnauthorizedAccessExcepÂ*tion: Access is denied." on
the following line of code:

oSummProps.Title = myNewTitle

Therefore, I was able to open the file, and it was not read-only. (If you
don't have read/write access, it still opens the file as read-only.)

And Patrice, I took your advice with the filemon...it shows a successful
CREATE request and a successful CLOSE request. Unfortunately, the attempt to
set the title in the line of code above is not logged.

Also, I took the advice of Ken Cox (http://tinyurl.com/7sleo) to change the
ASPNET account from machine to SYSTEM, but that didn't seem to have any
greater effect.

Any other ideas?

Thanks again!

Eric
"Paul Clement" wrote:
On Tue, 11 Oct 2005 05:46:02 -0700, "Eric" <Er**@discussions.microsoft.com> wrote:

¤ Hello,
¤
¤ I am having some sort of security issue with my code. When I change a
¤ file's title in a Windows or console app, I have no problems. (I am using
¤ Microsoft's article & DsoFile.dll:
¤ http://support.microsoft.com/default...b;en-us;224351)
¤
¤ When I run it in ASP.NET, I get a "file not found" exception, even though
¤ the file does exist.
¤
¤ Here is what I have already tried within ASP.NET:
¤ 1. Launch the code in a console app in a separate process.
¤ 2. Launch the code as a web service...didn't think this would work since
¤ it's under IIS's jurisdiction as well, but tried anyway.
¤ 3. Both of the above two options while impersonating an admin account.
¤ 4. Steps 1 and 2 after fully trusting the assemblies (meaning every assembly
¤ in my solution).
¤
¤ Here is my code:
¤
¤ Dim oSummProps As DSOFile.SummaryProperties
¤ Dim oCustProp As DSOFile.CustomProperty
¤ Dim sFile, sTmp As String
¤ Dim m_oDocument As DSOFile.OleDocumentPropertiesClass
¤
¤ m_oDocument = New DSOFile.OleDocumentPropertiesClass
¤ ' Note: fileName is just a local file...in this case, c:\test.txt.
¤ m_oDocument.Open(fileName, False, _
¤ DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIf NoWriteAccess)
¤
¤ If Not m_oDocument.IsReadOnly Then
¤ oSummProps = m_oDocument.SummaryProperties
¤ oSummProps.Title = myNewTitle
¤ m_oDocument.Save()
¤ End If
¤ m_oDocument.Close()
¤ m_oDocument = Nothing
¤
¤ Does anybody know what to do here?

I would agree that there is a permissions problem. It isn't clear though where these files are
located or how you have implemented impersonation in your web application.
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 19 '05 #4
On Tue, 11 Oct 2005 10:04:10 -0700, "Eric" <Er**@discussions.microsoft.com> wrote:

¤ Thank you for your replies, Patrice and Paul.
¤
¤ I think you two nudged me a little in the right direction...not quite there
¤ yet, but close. I explicitly set the NTFS permissions on the directory to
¤ allow the ASPNET account full access. Now, instead of the "file not found"
¤ exception, I get "System.UnauthorizedAccessExcep*tion: Access is denied." on
¤ the following line of code:
¤
¤ oSummProps.Title = myNewTitle
¤
¤ Therefore, I was able to open the file, and it was not read-only. (If you
¤ don't have read/write access, it still opens the file as read-only.)
¤
¤ And Patrice, I took your advice with the filemon...it shows a successful
¤ CREATE request and a successful CLOSE request. Unfortunately, the attempt to
¤ set the title in the line of code above is not logged.
¤
¤ Also, I took the advice of Ken Cox (http://tinyurl.com/7sleo) to change the
¤ ASPNET account from machine to SYSTEM, but that didn't seem to have any
¤ greater effect.
¤
¤ Any other ideas?

OK, well I have same two questions as in my prior reply but I will be more specific. ;-)

How did you implement impersonation? Did you enable the option in web.config? Are you impersonating
the authenticated user (via Integrated Windows or Basic auth)?

Where are the files located? Are they on the web server or a remote network machine?
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anthony Liu | last post by:
I copy-pasted the following sample xml document from http://slis-two.lis.fsu.edu/~xml/sample.html and saved it as samplexml.xml. Please note that I removed the following line <!DOCTYPE...
1
by: K R | last post by:
Hi, I have generated this XML from my application. But, when I open this XML, it is throwing error. Please help me to resolve this. <?xml version="1.0" encoding="utf-8" ?> <searchResults>...
3
by: K R | last post by:
Hi, I have generated this XML from my application. But, when I open this XML, it is throwing error. Please help me to resolve this. <?xml version="1.0" encoding="utf-8" ?> <searchResults>...
2
by: Santosh | last post by:
When you right click on file and select properties option, some files have "Summary" tab. Using ApplicationInfo.cs file we can set "Company","Language","Version" etc.. which appeares under...
5
by: Ram [MSFT] | last post by:
Hi All, I'm trying to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a...
0
by: MS | last post by:
Is the schema used to validate XML Documentation Comments available to be changed by a VS.Net user? I suspect the this question is no so have a couple of requests: 1.) I use #region...
1
by: Michael Reynolds | last post by:
I can read file attributes just fine (author, title, etc,) But there's no way to update them. I know windows application can do it, but can a web application update these file attributes? ...
6
by: Mag Gam | last post by:
Hi All, I am new to XML, and trying to extract some data from a file. The file looks like this: <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST>...
7
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.