You should be able to do it. If you're working with a subscription (aka ArcGIS Online for organizations), you probably need to pass some credentials to search the organization's items. Sorry, I can't tell you how to do this. You might try cross posting in the JavaScript API forum.
Mike