04/26/2011

RESTful web services use HTTP Methods: GET, POST, DELETE, PUT. You do not use the URL or the request body to specify the method.

RESTful web services use URLs specify what objects should be operated upon.

RESTFUL web services use HTTP status codes as return values.

The HTTP request body of a RESTful web service call is used only for data - not to specify the method, target objects, or return value.

The point of writing web services using REST is to take advantage of the simplicity of the HTTP protocol, and not to work against it. Your web service calls end up being very simple and easy to understand.

Here's an example of using a REST web service. This is a javascript function that retrieves a task object from the web service.

04/18/2011

The two links below pretty much cover it. I had trouble pulling the file binary out at first. I was originally decoding the entire body as a UTF-8 string, and then decoding the file binary back into a binary to store in the database, but that was causing it to become corrupt. As antscode shows, you just want to find the start and end index of the binary, then copy it.

Then visit the PayPal Tools page and read about each product to see which one you need. There's also a tool to help you decide, and you can watch videos about them on the training and tutorials page.

At this point, you probably want to read the Apps 101 page. It explains how you make apps that use PayPal to process payments.

Finally, go to the main page for whichever product you're going to use, and start digging into the documentation and the SDK.

Other Helpful Notes

Some other things confused me, so here is what I've learned. Please correct me if I'm wrong and I'll keep this updated.

2 Kinds of PayPal Apps - Most of us are just using PayPal to process payments. But now PayPal has a new kind of app you can develop, and it's referred to as a PayPal App - confusing, right? This new kind runs on PayPal to augment PayPal's features.

03/10/2011

What if there was a software platform where it helped you start a business?

Let's say you're a handy-man, and you know a lot about fixing stuff, and you're ready to start your own business doing it. But you don't know anything about starting a business and you are worried about the risk involved in it - losing money, getting into debt, getting into legal trouble.

So we could make a software package that you drop onto your desktop, and it guides you. You tell it "I want to start a business", and it asks you what kind. Then you tell it, and from there it starts prescribing different options to you to help you get started. Once you do get started, then it also helps you take care of the business issues, like accounting and legal issues. It would be sort of similar to a workflow/business logic system.

01/19/2011

Seems that if the last thing you draw on a Graphics2D object is a BufferedImage, then none of the other graphics appear. Why???

If you find that drawing an image causes missing graphics elements, draw something else afterwards, because that seems to clear up the problem. You can draw something that won't be seen, like a 0x0 rectangle.

09/30/2010

UPDATE: Since the time of the post, I have determined that my original suspicions were incorrect. So here is an update with what I've learned. The original post is at the bottom. I always try to make my articles as short as possible, but this is just one of those ones that requires a lot of explanation.

I had a problem using an Integrated Security connection string to connect to SQL Server 2008. This was in a SharePoint farm in which I was developing a custom SharePoint solution, but it applies to any ASP.NET application. The connection happened to work when I switched from "Integrated Security=SSPI" to "Integrated Security=True", but that was only coincidence. Those two values have the same effect.

I was actually experiencing two problems at the same time. First, Internet Explorer's Enhanced Security Configuration (IE ESC) was interfering with authentication in one situation. And second, I was experiencing a "double-hop" problem in another situation. If you don't know about NTLM double-hop, learn about it, because it's very important in Windows environments, especially for web apps. Basically, with NTLM, which is your standard Windows authentication, you are only allowed to transfer your Windows credentials out to one machine - a single hop from one machine to another. If an app attempts to transfer your credentials to another machine - a double-hop - you get the dreaded "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'".

So, here was the setup. I had three machines involved. Server A was a SharePoint WFE hosting Central Administration. Server B was an SQL Server (2008) hosting the SharePoint databases, and I was also using it for my custom SharePoint solution's database. And finally, I had a desktop client that I used just to browse/test SharePoint.

Now, most are probably having trouble with the ANONYMOUS LOGON thing, so I'll explain why that failed first. Let's say I'm on the desktop client. I browse to SharePoint (or some ASP.NET web app), and I log in - that's one hop. Now, the custom aspx page is doing a connection to the database. In this scenario, it's connecting as the logged-in user, me, using Windows Integrated Security and NTLM. So when it initiates the connection, there is a hop to access the SQL Server. You can't send Windows credentials on a second hop in NTLM, so the connection is made using ANONYMOUS LOGON. And of course, he has no permission to anything, and so the login fails.

Again, this same issue is likely to occur in any web app connecting to an SQL Server database using Windows authentication under NTLM, which is your default Windows authentication protocol. You either have to change to Kerberos protocol (hard, more secure, more flexible), or switch to SQL authentication on your database (easy, less secure).

As for the IE ESC issue, that was making things really tricky, and it is part of what led me to believe that there was a difference between "Integrated Security=SSPI" and "Integrated Security=True". On this one, I'm not very sure what is going on, but if you have ESC enabled, it seems to block the delegation of the Windows credentials to the second machine. You see, I was on Server A, the SharePoint WFE w/CA, and I was testing my custom add-in there. Over time, I found that if I disabled ESC, everything worked just fine. I couldn't understand why I didn't get a double-hop here too, but I think it's because I was on the same machine as the web app. So watch out for IE ESC, and it's probably best to test on a different machine anyway, because that's how the security and everything is designed to work.

ORIGINAL POST BELOW

I've been experiencing a problem using an Integrated Security to connect to SQL Server 2008. On server A, I have an aspx page that is trying to connect to an SQL server on server B. The connection is created via the SqlConnection object. When I use an SQL authentication mode connection string, everything works fine. But when I use a Windows authentication connection string, using "Integrated Security=SSPI", I get the error "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. Reason: Token-based server access validation failed with an infrastructure error."

What finally solved this problem is changing the connection string to "Integrated Security=True". Once I did that, everything worked fine.

Now, I did a lot of digging, and I could not find any explanations about why this happened. According to the SqlConnection documentation, "Integrated Security=SSPI" is equivalent to "Integrated Security=True", but obviously that's not true.

One thing I would like to mention is that these servers are part of a SharePoint farm. That makes this a different situation from the usual "login failed for NT AUTHORITY\ANONYMOUS LOGON" problems. The two WFEs are connecting to the SharePoint databases just fine, and the application is a custom application page running in the Central Administration site. The service accounts for everything including the web application identities are domain user accounts, and so we know that those user accounts are able to connect to the remove SQL server, and this application page should be able to as well. This information is what made me decide to try twiddling the Integrated Security value.

I wonder what's really going on here... SqlConnection must be handling the two options differently, but why is it failing with the one? Perhaps something is misconfigured, and it just happens to work with the method that SqlConnection uses for the "Integrated Security=True" connection string.

08/18/2010

I've been wondering how SharePoint list field types map to SQL data types. I did some web searches but didn't find what I was looking for, so here's a link to the documentation explaining this (WSS v3): http://msdn.microsoft.com/en-us/library/ms437580(v=office.12).aspx. And here's a table of mappings as documented for the Type attribute.

SharePoint Field Type

SQL Data Type

AllDayEvent

bit

Attachments

bit

Boolean

bit

Calculated

sql_variant

Choice

nvarchar

Computed

ContentTypeId

varbinary

Counter

int

CrossProjectLink

bit

Currency

float

DateTime

datetime

File

uniqueidentifier

GridChoice

ntext

Guid

uniqueidentifier

Integer

int

Lookup

int

LookupMulti

ModStat

int

MultiChioce

ntext

MultiColumn

Note

ntext

Number

float

PageSeparator

Recurrence

bit

Text

nvarchar

ThreadIndex

varbinary

Threading

varchar

URL

nvarchar

User

int

UserMulti

WorkflowEventType

WorkflowStatus

nvarchar

On the empty ones, I'm not sure what the type should be or if there is even supposed to be a type.

08/16/2010

Ok, so I ran into this networking problem last week, and it took me a bit to figure it out, so I'll explain the problem and how I fixed it here.

SUMMARY

You are logged in as a user on machine A. You try to view shared folders on machine B. You get the logon failure. That's because the user is not allowed to log into or share files with machine B. Add the user to the remote users group on machine B. The machines have to be in the same workgroup or domain for you to do this.

DETAILS

I recently got a brand new Windows 7 desktop to work from home, but I also have this old Windows XP desktop at home that I've been using for personal stuff and remoting into work. I wanted to give my work computer access to my home computer so that I could just copy some of the files (The Longest Journey! :D) over as needed. My new win 7 desktop is MACHINE_A, and my home desktop is MACHINE_B.

The problem I hit was that when I tried to browse to \\MACHINE_B, MACHINE_A would say the logon failed because the user had not been granted the requested logon type at the computer. The thing that really confused me was that when I first tried to explore \\MACHINE_B, it would prompt me for a u/p, and I would put in the one for MACHINE_B\admin, and it would churn for a moment, and then it would give that error. Here's what happened.

MACHINE_B was on workgroup settings, and MACHINE_A was on the work domain. I was logged into MACHINE_A as DOMAIN\userOnA, a user that was unknown to MACHINE_B. MACHINE_B gave remote access only to administrators, which is why userOnA was blocked, even with the correct u/p. I had the right authentication, but not the right authorization. I tried to add userOnA somehow, but I couldn't. I probably could have opened MACHINE_B wide open so that anything could access it, but I didn't want to do that.

Eventually, I figured out that I needed to put MACHINE_B on the work domain so that I could select user objects from it, and add them to the remote users. That would let me add userOnA to MACHINE_B's remote users, which means that if userOnA were authenticated, then he could also perform remote actions like sharing files from MACHINE_B. I joined MACHINE_B to the work domain, logged in as admin, added userOnA to the remote users, went over to MACHINE_A, explored \\MACHINE_B, and I was able to see the shared folders.

Actually, to tell you the truth, I could be mistaken about how I explained some of these things, but based on what I did and what worked, these are the concepts that I drew. In any case, I hope this helps you out!