Anonymous Access Gotcha for Custom SharePoint Code 

Tags: Programming Extensions

It's a simple problem with a simple solution, but sometimes the little things hit you when you are deploying from one environment to another and they can take a lot longer than you'd like.  So, hopefully this is a reminder and saves some people some time...
 
Recently I wrote a couple of web services to be hosted within SharePoint.  This problem wouldn't only occur with web services, though.  It could happen with web parts, application pages, site pages, event handlers, etc.
 
One of my web services did not access the SharePoint object model, but needed to know who the current user was, so it used the following within its code:
 
HttpContext.Current.User.Identity.Name;
 
Another web service did use the SharePoint object model and it used the following:
 

this.Context.User.Identity.Name

SPContext.Current.Web.CurrentUser.Groups

 
The code above worked beautifully in my development environment and two other test environments.  When it came time to deploy to test environment at the client, they didn't work.  I was perplexed.
 
Based on the exception I had I ascertained that CurrentUser was null in the code above and asked the testers if they were logged in - assuming anonymous access must have been enabled and that they were not logged in.  Well, they were logged in, but anonymous access was enabled - and that was the difference in the environments that worked and didn't work.
 
It turns out that the problem was that the SharePoint web application (and therefore IIS) allowed anonymous access  and the client to the web service calls (in this case InfoPath Forms Services) had negotiated to send as little credentials as possible (none).
 
So, the first two code snippets resulted in a null or empty string and the last code snippet blew up because CurrentUser was null.
 
The solution was simple...  Require an IIS change to the asmx file or its containing folder to not allow (uncheck) anonymous access to the web service(s).
 
Another option might be to modify the code to return a 401 Unauthorized to see if the negotiation would begin.  I didn't take it that far, but would love to hear from someone if they have tried this.
 
 
 
Posted by Kirk Liemohn on 1-Jul-08
10 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments


Prien commented on Tuesday, 21-Oct-2008
Specifying a custom template 1. If the library is not already open, click its name on the Quick Launch. If the name of your library does not appear, click View All Site Content, and then click the name of your library. 2. On the Actions menu, click Open with Windows Explorer. 3. In Windows Explorer, browse to find the custom template that you created. 4. Right-click the file, and then click Copy on the shortcut menu. 5. Click the Back button until you return to the library, and then click the Forms folder to open it. 6. Right-click in a blank area in the folder window, and then click Paste on the shortcut menu. 7. Close Windows Explorer and return to the library on the site. 8. On the Settings menu, click Form Library Settings. 9. Under General Settings, click Advanced settings. 10. In the Document Template section, type the address of the template that you want to use in the Template URL box. The location is the Web address of the template on the SharePoint site, relative to the name of the site. For example, if your template is called Orders.xml, and you add it to the Forms folder of the Shared Documents library, you would type /Shared Documents/Forms/Orders.xml in the Template URL box. If the settings in the Document Template section are not available, multiple content types may be enabled. To see whether multiple content types are enabled, verify that Yes is selected under Allow management of content types in the Content Types section. If it is, you must edit the template for the content type, if you have the permission to change the settings for the library.


wow commented on Thursday, 30-Oct-2008
lc Welcome to wow gold. We are a world class wow powerleveling store online. We supply cheap wow gold to our loyal and World of Warcraft goldreliable customers. you canwow power leveling buy really cheapwow gold wow gold here. We havewow power leveling mass available stock ofwow power leveling wow gold onwow power leveling most of the servers, sowow power leveling that we can do aRolex really instant way of wow power levelingwow gold wow golddelivery. We canwow powerleveling deliver yourwow powerleveling wow gold on powerlevelingthe order powerlevelingin a short cheap wow goldwhile. We have beencheap wow gold an ebay powerpower leveling seller and paypalpower leveling confirmed seller rolex replicaof wow gold for replica rolexyears.So it ischeap wow gold securest and safestRunescape Gold to buy RuneScape Money wow gold from Watches Rolexus. Don’t be Rolex Watchesirresolute! We arewow gold hoping to servegold wow you and helpingWatch Rolex you to have a wonderfulRolex Watch wow life! We arers gold ready now, how about you?


wow commented on Thursday, 30-Oct-2008
lc Welcome to wow gold. We are a world class wow powerleveling store online. We supply cheap wow gold to our loyal and World of Warcraft goldreliable customers. you canwow power leveling buy really cheapwow gold wow gold here. We havewow power leveling mass available stock ofwow power leveling wow gold onwow power leveling most of the servers, sowow power leveling that we can do aRolex really instant way of wow power levelingwow gold wow golddelivery. We canwow powerleveling deliver yourwow powerleveling wow gold on powerlevelingthe order powerlevelingin a short cheap wow goldwhile. We have beencheap wow gold an ebay powerpower leveling seller and paypalpower leveling confirmed seller rolex replicaof wow gold for replica rolexyears.So it ischeap wow gold securest and safestRunescape Gold to buy RuneScape Money wow gold from Watches Rolexus. Don’t be Rolex Watchesirresolute! We arewow gold hoping to servegold wow you and helpingWatch Rolex you to have a wonderfulRolex Watch wow life! We arers gold ready now, how about you?


summ commented on Thursday, 6-Nov-2008
Voordat we echt vanstart gaan met Age of Conan, wil ik toch twee dingen even gezegdmaplestory mesos hebben. Allereerst maak ik heel kort even maple story mesosplek om de systeemeisen onder de aandacht te brengen. Je hebt flink wat vrije ruimte op je harde schijf nodig en je hardware moet niet al te oud zijn, wil je deze game soepel draaien. Je krijgt er echter wel heel maple story mesoveel grafische pracht en praal voor terug, dus wat mij betreft zijn die systeemeisen makkelijk te > rechtvaardigen. Het tweede punt is misschien wel wow goldéén van de meest gevoelige onderwerpen binnen de wereld derwow gold games: het maandelijks betalen voor een game. Veel MMO’s hanteren wow goldabonnementen waarbij je maandelijks tussen dewow gold 10 en 15 euro moet neerleggen om te blijven spelen, en wow goldAge of Conan is hier geen uitzondering op. Ik wil me niet mengen in de discussie of dergelijke vaste lasten een goede zaak zijn of niet, dat is een persoonlijke overweging wow goldom te maken. MMO’s zijn games met een ongekende levensduur, dito ondersteuning wow golden veel extra content. Ben je bereid om je volledig te verliezen in een langdurig avontuur, dan is Age of Conan wow goldecht iets voor jou.wow gold Voor de gelukkigenwow power leveling onder ons die de beta mochten spelen, of voor alle anderen die natuurlijkwow gold onze preview hebben gelezen, moge het wow goldduidelijk zijn dat Age of Conan veel mogelijkheden biedt om een character aan te maken en deze van een eigen stijl te voorzien. Je krijgt veel tot je beschikking om je personage vorm wow goldte geven in het begin, van de grootte van wow goldje neus tot aan de meest obscure wow power levelingtatoeages. De enige beperking wow golddie je wordt opgelegd, is dat je character menselijk is en menselijk blijft. Geen toffe trollen, kinky kabouters of extreme elfjes, je zult het binnen één van dewow power leveling drie menselijke volkeren wow power levelingmoeten zoeken.


情趣用品 commented on Tuesday, 18-Nov-2008
情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,按摩棒,跳蛋,充氣娃娃,免費A片,AV女優,美女視訊,情色交友,免費AV,色情網站,辣妹視訊,美女交友,色情影片,成人影片,成人網站,A片,H漫,18成人,成人圖片,成人漫畫,情色網,日本A片,免費A片下載,性愛,A片,色情,成人,做愛,情色文學,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色,情色視訊,免費成人影片,視訊交友,視訊聊天,視訊聊天室,言情小說,愛情小說,AIO,AV片,A漫,av dvd,聊天室,自拍,情色論壇,視訊美女,AV成人網,色情A片,情趣用品,A片,免費A片,AV女優,美女視訊,情色交友,色情網站,免費AV,辣妹視訊,美女交友,色情影片,成人網站,H漫,18成人,成人圖片,成人漫畫,成人影片,情色網,sex,情趣用品,A片,免費A片,日本A片,A片下載,線上A片,成人電影,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,微風成人區,成人文章,成人影城,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,臺灣情色網,色情,情色電影,色情遊戲,嘟嘟情人色網,麗的色遊戲,情色論壇,色情網站,一葉情貼圖片區,做愛,性愛,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,美女交友,做愛影片,情境坊歡愉用品,情趣用品,情人節禮物,情惑用品性易購,av,情趣用品,a片,成人電影,微風成人,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,愛情公寓,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,色情,寄情築園小遊戲,情色電影,aio,av女優,AV,免費A片,日本a片,美女視訊,辣妹視訊,聊天室,美女交友,成人光碟


wow gold commented on Thursday, 20-Nov-2008
Love is balmy wind that sooths wow goldpain and anxiety from the tempests of the life.Love is the teacher’s persisting in giving lectures when he is ill.


wow gold commented on Thursday, 20-Nov-2008
Love is awow gold key to open wow golddoor of a closed her heart. because the Love is an oasis on a boundless desert which gives a wow goldtired walkerwow gold strength and hope.Love is a harbor in a turbulent sea which makes a weary seaman safe and wow goldsound.Love is balmy windwow gold that sooths pain and anxiety from the tempests of the life.Love is the teacher’s wow goldpersisting in giving lectures when he is ill.Love is passing a cup of tea to teachers during the break.Love is sending postcards to parents on their birthdays.Love is a kind of subtle and precious sensation among human beings.Love is all.


wow gold commented on Thursday, 20-Nov-2008
Michael is the kind ofdofus kamas guy you love to hate. He is always in a good kamas dofusmood and always has acheter kamassomething positive to say. When someone would ask him how hewasdoing, he would reply, "If I were any better, I'd be twins!" He was a natural buy kamasmotivator. If an employee was having a bad day, Michael was there telling the employee how to look on the positive side of the situation. Seeing this style really made me curious, acheter dofusso one day I went up to Michael and asked him, "I don' t get it.


wow gold commented on Thursday, 20-Nov-2008
WHATEVER LOVE MEANS—DIANA Although world of warcraft goldneither or them remembered the occasion,wow po Diana first met her future husband when she was just ababy. It happened during the winter of 1961, when twelve-year-old Charles, Prince of wow orWales, was visiting his mother’sbuy wow gold Sandringham retreat. At the time, yourcheap wow goldPrince Charles barely glanced wow power levelingat the tiny baby sleeping in her cot. wow powerlevelingAfter all, bow could a dofus kamastwelve-year-old boy be kamas dofusinterested in babies? Lord of the Rings Online GoldBut the Prince would eventually LOTRO Goldtake a very keen interest in this particular baby —it LOTR Goldwould just take some time. In fact, age of conan goldit would be sixteen years before Prince Charles and Lady Diana Spencer tookage of conan power leveling place in the middle of a farmer’s field during a shooting party in November 1977.age conan goldIt was a cold, rainy, bleak afternoon when sixteen-year-old Diana, aoc gold dressed in a borrowet was too large for her, aoc power levelingboots, and blue jeans, crossed the field to meet aoc levelingthe heir to the British throne. It was almost twilight when the two came face to face near Nobottle Woods. Maple Story meso“What a sad man,” Diana thought when she first sawhim.Maple Story Mesos The future Princess was intrigued to finally meet the most eligible bachelor in England, maplestory Mesos thought she was not impressed with his five-foot-ten-inch height,fly for fun penya thinking to herself that she would tower over him in high heels. flyff penyaBut Diana would later sadmired his beautiful blue eyes.buy flyff goldThe Prince later remarked that he thought Diana was flyff money“a very jolly and attractive” girl, “full of fun,” though Diana herself believed that “he barely oticed me at all.”ffxi gil Diana, it was discovered later, first came to the attention of the royal buy ffxi gil family when she acted as a bridesmaid for Final Fantasy XI gil her sister Jane’s wedding that April. buy cheap ffxi gilIt was the first major social occasion that Diana attended as a young woman. And many of the royals were surprised at how beautiful and mature final fantasy 11 cheap gilthe once-gawky girl had become. Even the Queen Mother. Prince Charles’s grandmother, buy Warhammer goldnoticed Diana’s beauty, grace, and charm. She complimented the Earl on theWarhammer gold fine job he had done in bringing Diana up. A short time later, Prince Charles sent his valet to hand-deliver a formal invitation for Diana to accompany him that very evening to the opera and a latenight dinner at the palace. Though she was flustered, and the invitation came at such short notice, buy Warhammer gold accepted. She and her roommate, Carolyn Bartholomew, hurried to dress and prepare Diana for her big date. The evening was a success, and an invitation to party on the royal yacht came soon after…… Although she was intimidated by the crowd at Balmoral, Warhammer goldDiana was wise enough not to stay in the castle itself . She asked for, and was granted, an invitation to stay with her sister Jane and her young husband at their cottage on the Balmoral estate. silkroad online goldThe Prince visited Diana there every day, SRO gold offering to escort her to a or extending an invitation for a long walk in the woods. Silkroad goldbuy silkroad goldWhen Charles went to Switzerland fo, ffxi gilDiana missed him terribly. He called her after a day or two, and told Diana he had something important to ask her.Final fantasy xi gil He arrived home on February, 3,buy ffxi gil 1981.Three days later, final fantasy 11 cheap gil he arrasee Diana at Windsor Castle. Late that evening, while Prince Charles was showing Diana the nursery, he asked her to marry him.

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation