Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

How can I pass Windows credentials on my


  • Please log in to reply
1 reply to this topic

#1 Chiodino72

Chiodino72

    New Member

  • Members
  • Pip
  • 1 posts

Posted 13 March 2013 - 10:47 AM

Hi All,

I would like to pass my Windows credentials from a simple http client for Netduino plus 2

 

this is the approach I am taking but I haven't being successful so far..

NetworkCredentials class I understand does not support NTLM and I cannot use CredentialCache in the .net micro framework

Should I inject the credentials in the header? if yes how?

 

Thanks in advance

 

var sample = "test this";


byte[] buffer = Encoding.UTF8.GetBytes(sample);

 

// produce request

var requestUri = @http://SomeWhereThat...hentication.com;


 

using (var request = (HttpWebRequest)WebRequest.Create(requestUri))

 

{


 

request.Method = "POST";


string username = @"myusername";

string password = "mypwd";

 

NetworkCredential myCred = new NetworkCredential(username, password);

 

// headers

request.ContentType = "application/json";

 

request.ContentLength = buffer.Length;


//request.Headers.Add("Authorization", "NTLM " + authInfo); is this a good lead?!?!?


 

request.Credentials = myCred;

 

request.Credentials.AuthenticationType = AuthenticationType.Basic;


 

request.KeepAlive = false;


 

// content


 

Stream s = request.GetRequestStream();


 

s.Write(buffer, 0, buffer.Length);



 

// send request and receive response


 

using (var response = (HttpWebResponse)request.GetResponse())


 

{


 

// consume response


 

Debug.Print("sample: " + sample);


 

Debug.Print("request uri: " + requestUri);


 

Debug.Print("Status code: " + response.StatusCode);


 

}


 

}



#2 neographikal

neographikal

    New Member

  • Members
  • Pip
  • 9 posts

Posted 23 March 2013 - 10:52 AM

I haven't done this, so no clue how you can do it ON the netduino. Another option is to use a bridge, create a asp.net website that gets the requests from the Netduino and forwards it along with the authentication. Would that be an solution?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.