Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

webznz

macrumors member
Original poster
Mar 8, 2011
82
0
Hobbitin
Hi, I am graduate developer and am looking for help on this simple application I'm making.

My question is, is it possible to supply a user name and password along with the NSURLconnection request when trying to connect to a database that requires a login.

if so are there any examples you could provide me with. Any help would be greatly appreciated.
 
That has nothing to do with NSURLConnection, that's entirely within the HTTP spec.


Code:
http://username:password@www.myhost.com/aDirectory/aFile.php?aRequestParam=S
 
That will depend on how the login works. In general your delegate will get messages like connection:didReceiveAuthenticationChallenge: when a username/password challenge is received. I don't do examples: I would expect any graduate to be able to write code from the documentation.

Ha, didn't even think about this. I just recently had to do something like this quick and dirty like for an inhouse reporting app, and the easiest way was as I mentioned above.

To the OP, doing it as robbie mentions is the FAR superior way.
 
Thank you for the responses. Robbie, I am extremely new to objective C and iOS frameworks. I know I need to get better but I am doing my best, and would hope people would understand.
 
Thank you for the responses. Robbie, I am extremely new to objective C and iOS frameworks. I know I need to get better but I am doing my best, and would hope people would understand.

I do understand. But in my experience of trying to help people, both on these forums and as a lab demonstrator when I was at University, I have seen that giving people examples teaches them absolutely nothing. They copy and paste and don't know anything about what they have copied.

My suggestion: try stuff. When it doesn't work post your code, explain why you have done what you have done, explain what outcome you expected and what happened. Then you can be helped.
 
Ha, didn't even think about this. I just recently had to do something like this quick and dirty like for an inhouse reporting app, and the easiest way was as I mentioned above.

To the OP, doing it as robbie mentions is the FAR superior way.


Yes it is a good option from the research I have done, and was going to be my option of choice. But when I approached the database administrator for this application I am making he said that authentication challenge is not an option. But I am going to go back and talk to him about this because IMO it's the most secure...
 
I do understand. But in my experience of trying to help people, both on these forums and as a lab demonstrator when I was at University, I have seen that giving people examples teaches them absolutely nothing. They copy and paste and don't know anything about what they have copied.

My suggestion: try stuff. When it doesn't work post your code, explain why you have done what you have done, explain what outcome you expected and what happened. Then you can be helped.

Yep fair enough, I defiantly want to learn and understand what I am doing. And I know of the people you talk about :) never... never do group assignments with people like that, not unsless you are keen to do all the work yourself. lol
 
Yes it is a good option from the research I have done, and was going to be my option of choice. But when I approached the database administrator for this application I am making he said that authentication challenge is not an option. But I am going to go back and talk to him about this because IMO it's the most secure...

I would ask him to provide details on the login protocol. It sounds like the login is not running at the HTTP level so you will be doing all the login work yourself, rather than Apple's classes. Or you might be able to get an off-the shelf library that provides connectivity with login etc.
 
Yea, I need to pin him down and show him whats going on with the code.
I think the problem is He dose not understand what I'm doing and I don't understand what he requires of me. Think I better go talk to him again
 
There are several examples related to networking from Apple. Look at SimpleURLConnections and AdvancedURLConnections and maybe some others.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.