473,406 Members | 2,894 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,406 software developers and data experts.

Passing Credentials to WEBDAV

All,

I am doing a WEBDAV request and I want to pass the users Credentials to the
webdav server, eg some code like :

Request.Credentials = CredentialCache.DefaultCredentials;

This does not work, as I get AUTH FAIL, but if I pass the user name and
password by using :

MyCredentialCache.Add( new System.Uri(strRootURI),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword, strDomain)
);
Request.Credentials = CredentialCache.MyCredentialCache;

it works, but I don't want to hard code the username / pass and the username
/ pass must be the current user as this is an exchange WEBDAV request.

Steve
Nov 18 '05 #1
7 4833
I've added

<identity impersonate= "true" />

But this is not ideal as this is a WEBCONTROL ( Server Control) and I don't
want to insist that the user of the control have this option set.

Steve
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
All,

I am doing a WEBDAV request and I want to pass the users Credentials to the webdav server, eg some code like :

Request.Credentials = CredentialCache.DefaultCredentials;

This does not work, as I get AUTH FAIL, but if I pass the user name and
password by using :

MyCredentialCache.Add( new System.Uri(strRootURI),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword, strDomain)
);
Request.Credentials = CredentialCache.MyCredentialCache;

it works, but I don't want to hard code the username / pass and the username / pass must be the current user as this is an exchange WEBDAV request.

Steve

Nov 18 '05 #2
SF
Impersonation seems to be the right thing to do here. Without it,
you will get the aspnet-user credentials from the credential cache
which is why the authentication failed in the first place.

Can you elaborate why it isn't ideal for you?

Also, a good article/library on accessing Exchange with WebDAV
is here: http://www.codeproject.com/dotnet/exdav.asp?print=true

Might be worth checking out
-Stefan
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I've added

<identity impersonate= "true" />

But this is not ideal as this is a WEBCONTROL ( Server Control) and I don't want to insist that the user of the control have this option set.

Steve
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
All,

I am doing a WEBDAV request and I want to pass the users Credentials to

the
webdav server, eg some code like :

Request.Credentials = CredentialCache.DefaultCredentials;

This does not work, as I get AUTH FAIL, but if I pass the user name and
password by using :

MyCredentialCache.Add( new System.Uri(strRootURI),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword, strDomain) );
Request.Credentials = CredentialCache.MyCredentialCache;

it works, but I don't want to hard code the username / pass and the

username
/ pass must be the current user as this is an exchange WEBDAV request.

Steve


Nov 18 '05 #3
I am writing reusable server controls that can be use from a WEBPART
(sharepoint) or a webcontrol in a standard ASP.NET, so I don't want to be
force into changing the config of the webserver for that implementation.

but... if I have to then that's how it has to work.

Steve

"SF" <st****************@captaris.com> wrote in message
news:O%****************@tk2msftngp13.phx.gbl...
Impersonation seems to be the right thing to do here. Without it,
you will get the aspnet-user credentials from the credential cache
which is why the authentication failed in the first place.

Can you elaborate why it isn't ideal for you?

Also, a good article/library on accessing Exchange with WebDAV
is here: http://www.codeproject.com/dotnet/exdav.asp?print=true

Might be worth checking out
-Stefan
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I've added

<identity impersonate= "true" />

But this is not ideal as this is a WEBCONTROL ( Server Control) and I

don't
want to insist that the user of the control have this option set.

Steve
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
All,

I am doing a WEBDAV request and I want to pass the users Credentials to
the
webdav server, eg some code like :

Request.Credentials = CredentialCache.DefaultCredentials;

This does not work, as I get AUTH FAIL, but if I pass the user name
and password by using :

MyCredentialCache.Add( new System.Uri(strRootURI),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword,

strDomain) );
Request.Credentials = CredentialCache.MyCredentialCache;

it works, but I don't want to hard code the username / pass and the

username
/ pass must be the current user as this is an exchange WEBDAV request.

Steve



Nov 18 '05 #4
SF
In this case, you could try to make the WebDAV request and in case the
authentication fails, you could catch the Exception and redirect to a logon
form, where the user needs to provide the network credentials to use and
retry the request. Also, you can put the NetworkCredential object in session
and use it for subsequent WebDAV requests.

Is that viable?

"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
I am writing reusable server controls that can be use from a WEBPART
(sharepoint) or a webcontrol in a standard ASP.NET, so I don't want to be
force into changing the config of the webserver for that implementation.

but... if I have to then that's how it has to work.

Steve

"SF" <st****************@captaris.com> wrote in message
news:O%****************@tk2msftngp13.phx.gbl...
Impersonation seems to be the right thing to do here. Without it,
you will get the aspnet-user credentials from the credential cache
which is why the authentication failed in the first place.

Can you elaborate why it isn't ideal for you?

Also, a good article/library on accessing Exchange with WebDAV
is here: http://www.codeproject.com/dotnet/exdav.asp?print=true

Might be worth checking out
-Stefan
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I've added

<identity impersonate= "true" />

But this is not ideal as this is a WEBCONTROL ( Server Control) and I

don't
want to insist that the user of the control have this option set.

Steve
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
> All,
>
> I am doing a WEBDAV request and I want to pass the users Credentials to the
> webdav server, eg some code like :
>
> Request.Credentials = CredentialCache.DefaultCredentials;
>
> This does not work, as I get AUTH FAIL, but if I pass the user name and > password by using :
>
> MyCredentialCache.Add( new System.Uri(strRootURI),
> "NTLM",
> new System.Net.NetworkCredential(strUserName, strPassword,

strDomain)
> );
>
>
> Request.Credentials = CredentialCache.MyCredentialCache;
>
> it works, but I don't want to hard code the username / pass and the
username
> / pass must be the current user as this is an exchange WEBDAV request. >
>
>
> Steve
>
>



Nov 18 '05 #5
Sounds like a solutions, I will give it a try.
"SF" <st****************@captaris.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
In this case, you could try to make the WebDAV request and in case the
authentication fails, you could catch the Exception and redirect to a logon form, where the user needs to provide the network credentials to use and
retry the request. Also, you can put the NetworkCredential object in session and use it for subsequent WebDAV requests.

Is that viable?

"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
I am writing reusable server controls that can be use from a WEBPART
(sharepoint) or a webcontrol in a standard ASP.NET, so I don't want to be
force into changing the config of the webserver for that implementation.

but... if I have to then that's how it has to work.

Steve

"SF" <st****************@captaris.com> wrote in message
news:O%****************@tk2msftngp13.phx.gbl...
Impersonation seems to be the right thing to do here. Without it,
you will get the aspnet-user credentials from the credential cache
which is why the authentication failed in the first place.

Can you elaborate why it isn't ideal for you?

Also, a good article/library on accessing Exchange with WebDAV
is here: http://www.codeproject.com/dotnet/exdav.asp?print=true

Might be worth checking out
-Stefan
"Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
> I've added
>
> <identity impersonate= "true" />
>
> But this is not ideal as this is a WEBCONTROL ( Server Control) and I don't
> want to insist that the user of the control have this option set.
>
> Steve
>
>
> "Steve Drake" <Steve@_NOSPAM_Drakey.co.uk> wrote in message
> news:ue****************@TK2MSFTNGP11.phx.gbl...
> > All,
> >
> > I am doing a WEBDAV request and I want to pass the users Credentials
to
> the
> > webdav server, eg some code like :
> >
> > Request.Credentials = CredentialCache.DefaultCredentials;
> >
> > This does not work, as I get AUTH FAIL, but if I pass the user
name and
> > password by using :
> >
> > MyCredentialCache.Add( new System.Uri(strRootURI),
> > "NTLM",
> > new System.Net.NetworkCredential(strUserName, strPassword,
strDomain)
> > );
> >
> >
> > Request.Credentials = CredentialCache.MyCredentialCache;
> >
> > it works, but I don't want to hard code the username / pass and

the > username
> > / pass must be the current user as this is an exchange WEBDAV

request. > >
> >
> >
> > Steve
> >
> >
>
>



Nov 18 '05 #6
I know it has been a long time from the last thread but i'm having this problem to ..

Dim Cache As New System.Net.CredentialCache
Dim credential As ICredentials = CredentialCache.DefaultCredentials
Dim strAuthType As String = "Negotiate" 'Kerberos or NTLM return the same error
Dim uri1 As New System.Uri("http://exchange.gruporr.pt/exchange/pedro.bernardo")
Cache.Add(uri1, strAuthType, credential)
Dim session As WebdavSession = New WebdavSession("http://exchange.gruporr.pt/exchange/pedro.bernardo", Cache)

this is a simple webform app that i'm running on my localhost webserver IIS. The strange is that, when a changing the line : "Dim credential As ICredentials = CredentialCache.DefaultCredentials" to : "Dim credential As ICredentials = New System.Net.NetworkCredential("pedrobernardo", "mypassord", "mydomain")", it doesn't return the 401 error, instead it works fine.
Can you help me on this ?
Tks in advance
PedroBernardo
From http://www.developmentnow.com/g/8_20...-to-WEBDAV.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Mar 3 '06 #7
if this code in in a webapp, then the DefaultCredentials are the asp.net
account, which will not have network access. if you set identity
impersonate="true" in the web config, it should work from you local host.
note: the one hop rule will prevent it working if the browser is not on the
same server as the iis, unless you switch to kerberos and enable creditials
delegation on your servers.
-- bruce (sqlwork.com)
"Pedro Bernardo" <pe************@rr.pt> wrote in message
news:1c**********************************@msnews.m icrosoft.com...
I know it has been a long time from the last thread but i'm having this
problem to ..

Dim Cache As New System.Net.CredentialCache
Dim credential As ICredentials =
CredentialCache.DefaultCredentials
Dim strAuthType As String = "Negotiate" 'Kerberos or NTLM
return the same error
Dim uri1 As New
System.Uri("http://exchange.gruporr.pt/exchange/pedro.bernardo")
Cache.Add(uri1, strAuthType, credential)
Dim session As WebdavSession = New
WebdavSession("http://exchange.gruporr.pt/exchange/pedro.bernardo", Cache)

this is a simple webform app that i'm running on my localhost webserver
IIS. The strange is that, when a changing the line : "Dim credential As
ICredentials = CredentialCache.DefaultCredentials" to : "Dim credential As
ICredentials = New System.Net.NetworkCredential("pedrobernardo",
"mypassord", "mydomain")", it doesn't return the 401 error, instead it
works fine.
Can you help me on this ?
Tks in advance
PedroBernardo
From
http://www.developmentnow.com/g/8_20...-to-WEBDAV.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Mar 3 '06 #8

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

Similar topics

4
by: Jody Winston | last post by:
I'd like to present a view of an internal data store, which has Python interface built using SWIG, so that my users can traverse and manipulate the data store using familiar tools. My first...
0
by: Rade Josovic | last post by:
Hi, First implementation of WebDAV protocol is here: WebDAV .NET 1.0 from Independentsoft. Go to http://www.independentsoft.de The WebDAV .NET is WebDAV protocol API for Microsoft .NET...
3
by: Das | last post by:
Hi all, I'm writig an application that sends an http request to java servlet file. I have to pass an xml file to the servlet. How should I pass xml file to the file. When I try to access the...
7
by: Dennis C. Drumm | last post by:
I would like to be able to update an xml file located on my hosted server from my local computer. The server requires a user name and password to access the web site for writing or updating...
7
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the...
1
by: jadher | last post by:
I try to access an asp page in a machine that has windows integrated authentication turned on. I use System.Net.Networkcredentials as well as System.Net.Webrequest and Webresponse. I receive...
3
by: GRB | last post by:
My webiste has integrated windows authentication. I need to pass a clients credentials (username, password) to my site without the login pop up. I send the client to an anonymous page, get an...
2
by: Jay Balapa | last post by:
Hello, Win Forms app is able to connect to my webservice passing credentials as follows- myService.Credentials=System.Net.CredentialsCache.DefaultCredentials; Compact Framework does not...
0
by: arjen1984 | last post by:
I am now working on C# with WebDAV on Exchange now to get appointments. When I work local on the domain where the server is, i can get the appointments no problem. When I work outside of it, i get an...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.