this question solved framework 3.5, need using .net framework 2 , c#.
i want validate given domain\user , password combination. example:
username: thedomain\thename password: thepassword also note drawbacks suggested solutions given in link.
current solution using, note false negative possibilities
you can use networkcredential.domain property
the following code example uses domain property set domain associated credentials
// create empty instance of networkcredential class. networkcredential mycredentials = new networkcredential("", "", ""); mycredentials.domain = domain; mycredentials.username = username; mycredentials.password = password; // create webrequest specified url. webrequest mywebrequest = webrequest.create(url); mywebrequest.credentials = mycredentials; console.writeline("\n\nuser credentials:- domain: {0} , username: {1} , password: {2}", mycredentials.domain, mycredentials.username, mycredentials.password); // send request , wait response. console.writeline("\n\nrequest url sent.waiting response...please wait ..."); webresponse mywebresponse = mywebrequest.getresponse(); // process response. console.writeline("\nresponse received sucessfully"); // release resources of response object. mywebresponse.close(); here msdn link more reading
hope help
Comments
Post a Comment