469,272 Members | 1,587 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

401 Unauthorized trying to read SPList Attachment - owssrv.dll

We have written a class that enumerates the items in a WSS list and then
attemptes to open the attachment for each item. We have written two classes,
one to impersonate a user and read in the list information and the other to
be called by the first which actually opens the attachment. Our code fails
when it tries to open the attachment in the second class with a 401 -
Unauthorized error from IIS on http://localhost/_vti_bin/owssrv.dll. What's
strange is that I can use IE to open the URL to the attachemnt without any
problems. I noticed in the IIS logs that when I open the URL, I can see the
domain\password passed to IIS from IE. However, when our code tries to
access the same URL, no user information is passed, causing the 401. We have
impersonated a valid user in our code, so why does IIS not see it?

Thanks!
Nov 17 '05 #1
2 3696
Please do not post WSS programming questions in future to the main WSS
newsgroup but only to the newsgroup specially created for WSS programming
questions.

We are maintaining a clear split where WSS Programming questions go only to
microsoft.public.sharepoint.windowsservices.develo pment and not to the
(Administration issues) main newsgroup
microsoft.public.sharepoint.windowsservices.

This split is to the benefit of the readers of one or both these newsgroups.

Thanks.

Mike Walsh, Helsinki, Finland
WSS FAQ at http://wss.collutions.com
Please reply to the newsgroup

"Chris Kane" <Ch*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
We have written a class that enumerates the items in a WSS list and then
attemptes to open the attachment for each item. We have written two
classes,
one to impersonate a user and read in the list information and the other
to
be called by the first which actually opens the attachment. Our code
fails
when it tries to open the attachment in the second class with a 401 -
Unauthorized error from IIS on http://localhost/_vti_bin/owssrv.dll.
What's
strange is that I can use IE to open the URL to the attachemnt without any
problems. I noticed in the IIS logs that when I open the URL, I can see
the
domain\password passed to IIS from IE. However, when our code tries to
access the same URL, no user information is passed, causing the 401. We
have
impersonated a valid user in our code, so why does IIS not see it?

Thanks!

Nov 17 '05 #2
hi

i think the current context is associated with current logged in user
credentials so change the context.
string CurrentSiteUrl = SPControl.GetContextWeb(Context).Url;

start impersonation//username password etc

SPSite tmpSite = new SPSite(CurrentSiteUrl);
tmpSite.CatchAccessDeniedException = false;
SPWeb mysite= tmpSite.OpenWeb();

SPList lists=mysite.Lists["list name"];

undo impersonation

hope this helps

bart
"Mike Walsh" wrote:
Please do not post WSS programming questions in future to the main WSS
newsgroup but only to the newsgroup specially created for WSS programming
questions.

We are maintaining a clear split where WSS Programming questions go only to
microsoft.public.sharepoint.windowsservices.develo pment and not to the
(Administration issues) main newsgroup
microsoft.public.sharepoint.windowsservices.

This split is to the benefit of the readers of one or both these newsgroups.

Thanks.

Mike Walsh, Helsinki, Finland
WSS FAQ at http://wss.collutions.com
Please reply to the newsgroup

"Chris Kane" <Ch*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
We have written a class that enumerates the items in a WSS list and then
attemptes to open the attachment for each item. We have written two
classes,
one to impersonate a user and read in the list information and the other
to
be called by the first which actually opens the attachment. Our code
fails
when it tries to open the attachment in the second class with a 401 -
Unauthorized error from IIS on http://localhost/_vti_bin/owssrv.dll.
What's
strange is that I can use IE to open the URL to the attachemnt without any
problems. I noticed in the IIS logs that when I open the URL, I can see
the
domain\password passed to IIS from IE. However, when our code tries to
access the same URL, no user information is passed, causing the 401. We
have
impersonated a valid user in our code, so why does IIS not see it?

Thanks!


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jayakumar | last post: by
1 post views Thread by Dave | last post: by
2 posts views Thread by ALI-R | last post: by
reply views Thread by David Davis | last post: by
3 posts views Thread by Newbie19 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.