|
-
Aug 29th, 2006, 02:21 PM
#1
Thread Starter
PowerPoster
NetworkCredential help
Hi.
I have a local computer and another computer connected to the same network but not in a domain.
I want to access the other computer using a different username/password. An example would be, getting a list of files.
I have created a test user account on the other computer.
within my app, I always get the UnAuthorizedAccessException when trying to access the resource, even specifying and adding to the CredentialCache, the username/password of the account which allows access to that resource.
can someone please tell me, how can I access a resource giving it the credential to use?
Code:
NetworkCredential theCredential = new NetworkCredential("test", "test");
CredentialCache cc = new CredentialCache();
cc.Add(@"\\computer", 135, "Basic", theCredential);
string[] dirFiles = Directory.GetDirectories(@"\\computer\C");
//error at the last line
-
Aug 29th, 2006, 05:10 PM
#2
Thread Starter
PowerPoster
Re: NetworkCredential help
ive actually gotten a step ahead now by setting some permissions again on the share, this time i get an IOException stating invalid username/password.
However in Windows, if I access the share, I get prompted the username/password, I enter it (same as in code) and I can access it in Windows, then when I run the code again - viola - it works.
But I want to be able to access it within code rather than authenticating in Windows giving a username/password
-
Aug 29th, 2006, 08:20 PM
#3
Re: NetworkCredential help
Try setting the Domain property of the NetworkCredential object, either directly or by passing it to the constructor.
-
Aug 29th, 2006, 10:12 PM
#4
Thread Starter
PowerPoster
Re: NetworkCredential help
I also tried that but no luck
-
Jun 23rd, 2007, 10:28 PM
#5
Fanatic Member
Re: NetworkCredential help
This is what i have been trying to do as well
did you ever have any luck with this?
-
Jun 23rd, 2007, 10:46 PM
#6
Re: NetworkCredential help
vb Code:
Dim cre As New NetworkCredential(UserName, Password)
Dim progressStep As Integer = 100 \ Receivers.Count
Dim currentProgress As Integer
uxBackWorker.ReportProgress(currentProgress)
Dim smtp As New SmtpClient(SmtpServer)
For Each rec As String In Receivers.ToArray()
Dim msg As New MailMessage(UserName, rec, Subject, Body)
For Each atta As String In Attachments.ToArray
msg.Attachments.Add(New Attachment(atta))
Next
smtp.EnableSsl = True
smtp.Credentials = cre
smtp.Send(msg)
currentProgress += progressStep
uxBackWorker.ReportProgress(currentProgress)
Next
This is a VB code from one of my projects it's supposed to login to mail server and send an email. I hope it's good enough for you
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 24th, 2007, 12:05 PM
#7
Fanatic Member
Re: NetworkCredential help
no so much but i appreciates it
im trying to pass credentials to a computer so i can get a list of process's from it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|