CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

CAPTCHA for Community Server 2007

I'm happy to announce that CodeBetter.Com is carrying on the legacy of CAPTCHA for Community Server.  CAPTCHA for CS2007 is the next generation of CS Guru Dave Burke's most excellent CAPTCHA control for Community Server 2.1This version is implemented as a Control Adapter which allows CAPTCHA to be added to Community Server site-wide without touching any ASPX or ASCX markup code.

You can get the dll and source code here *.

* Latest Version -  April 29th 2007

IMPORTANT NOTE:  If the form in your ASPX control specifies a validation group, your controls must also specify the same group. Some skins that ship with CS2007 have a validation group specified for the form, but not for the controls.  The CAPTCHA control will not work for these forms.  To fix, either remove the validation group from the form code or add to all of your form's controls.

 EX:  Form specifying a validation group:

                <CSFile:CreateEntryCommentForm runat="server"
                        MessageTextBoxId="CommentBody"
                        NameTextBoxId="CommentName"
                        RememberCheckboxId="CommentRemember"
                        SubjectTextBoxId="CommentTitle"
                        SubmitButtonId="CommentSubmit"
                        UrlTextBoxId="CommentWebsite"
                        ControlIdsToHideFromRegisteredUsers="RememberWrapper,AnonymousUser"
                        ValidationGroup="CreateCommentForm"
                    >

 Must also specify the validation group in the controls to be validated:



Comments

Rory Primrose said:

Hi Brendan,

Thanks for your CAPTCHA control. I have implemented it on my site, but I still get spam comments. After testing it when logged out, I found that the CAPTCHA value wasn't checked and the comment was posted.

I did the same test on this comment by not entering a value, and it was checked. Any ideas?

Cheers,

Rory

# April 28, 2007 6:44 PM

Brendan Tompkins said:

Hmmm.. I'm not sure... Can you send me the URL so that I can test it?

# April 28, 2007 7:07 PM

Rory Primrose said:

Hi Brendan,

The url is http://www.neovolve.com. I followed the installation instructions so I'm sure I haven't missed anything.

Cheers,

Rory

# April 29, 2007 3:54 AM

Brendan Tompkins said:

Rory,

I found out this was due to some of the shipped skins with CS 2007 not specifying the ValidationGroup property of the forms correctly.  I've updated the code.  I'll update this post too to explain.

# April 29, 2007 11:39 AM

Rory Primrose said:

Thanks Brendan. The new dll works great now. I am assuming the change you made to the code was to assign the validationgroup value from the form to the CAPTCHA textbox.

# April 29, 2007 7:01 PM

Brendan Tompkins said:

Yeah.. I was doing that during development, since it seemed like the right thing to do, but I didn't realize I was working with a borked skin.  

I'm worried that some people trying this with the OOTB skins will have the same issues. To fix this, I added the Validation group of the form if present to the control adapter.. To get it to work on my forms, I had to add the validation group to all of the controls and submit button.

# April 29, 2007 7:58 PM

TrackBack said:

# April 30, 2007 9:02 AM

Scott Watermasysk said:

We will look into the validation group issue and put a fix in v.Next (or a SP).

Thanks,

Scott

# April 30, 2007 9:53 AM

KNOCKS said:

Hey, thanks for the great control!

Works like a charm

# May 1, 2007 3:41 PM

Yama said:

I followed your instruction but probably misssed something because it hasn't worked for me. I am using the PaperClip Theme and I did delete the ValidationGroup="CreateCommentForm"from the post.apsx form in the paperclip folder. But still no luck. Do we need to include a .NET generic handler file captcha.ashx in th blogs folder? Please guide me... :-)

# May 3, 2007 10:54 PM

Brendan Tompkins said:

Yama:  Try adding the Validation Group back in and adding it to each of the text box controls & validators and the link button control as well.

# May 4, 2007 1:29 PM

Yama said:

How can I do that? I was unclear by that? The control works when I delete browser cookies, etc... but it works only once then magically stops to work? My image folder has got every rights enabled. Are there other folders I need to change rights to? Most of the folders under CS web folder have read and execute permissions. The blogs, forum/storage, photos/cache, photos/storage, sitefiles, theme/blogs/paperclip/images folders all have full permission... Am I missing something else? Oh yes please then explain to me how I can add the validator group to a control... An example on a single control should explained it all to me. Many thanks.

# May 4, 2007 3:16 PM

Brendan Tompkins said:

Hmmm. not sure.. Just add the attribute ValidationGroup="CreateCommentForm" to all of your controls in the form you're using this on.  Eg. textbox runat=server ValidationGroup= etc.  and then add that tag to the link button on that control as well.. I'm not sure I can explain it a whole lot better than that.

# May 4, 2007 3:39 PM

Yama said:

Thanks Brendan... I will keep you posted on tip and tricks I learn while implementing this to my blog @ http://yama.yamabiz.com. Give me a couple of days. I have it working now on the blog forms but it goes crazy on the contact form now... But let me try some stuff here and oh by the way a million thanks to shre the code cause without it I'd have been left in a realm of dilemna.

# May 4, 2007 4:02 PM

Yama said:

Can you please ping me at yama_nospam_at_yamabiz_dot_com? Please strip out the nospam. I will email you some improvements to your code for your next release. I will plublish a short excerpt of my work on the my blog and redirect them to this article if the wish to download code.

# May 6, 2007 12:12 AM

Rex Tang said:

Same problem as Yama had that the CAPTCHA is not working on my CS2007 site. it seems that the settings of ASP.NET Control Adapter in default.browser file is not working at all. any ideas??

# May 8, 2007 2:41 PM

Rex Tang said:

It's working now in my site. thanks for Yama's point out.

this control will not appear if one is in a logged in session. it will appear in an anonymous session without problems.

thanks for this great control...

# May 9, 2007 2:00 AM

evereq (Ruslan Konviser) said:

Hi! :) i just today spend 2 hours to rewrite Captcha from Dave Burke to working in CS 2007, but after i rewrite it, found some questions. I see that both you and Dave store Captcha code in cookie :) i store it in Page.Session :) So question: if you store it in Cookie you don't think that any client can also see it, without image processings etc? ;-) I.e. i can right now on this page View Cookie in my Firefox! What for then your captcha? Just to have user new task? ;-) Or i am wrong? ;-)

Better if i am wrong and all ppls that use your wonderfull code not have problems with spam :)

P.S. This comment posted with Bot, even Captcha in cookie can't help :D Joke!

# June 13, 2007 11:21 AM

Brendan Tompkins said:

Yep they could just inspect the cookie and pass back that value.  In order for a spammer to do it with a bot, they'd have to code it to look for the cookie, which admittedly wouldn't be that hard, but probably not something that a spammer would be motivated to do..  

It's a deterrent, and is easily broken, but works.

# June 13, 2007 11:39 AM

evereq (Konviser Ruslan) said:

Sorry, completly not understand your explanation :)

I really don't understand why needs create Captcha if its not working to prevent Bots :) "probably not something that a spammer would be motivated to do.. " :D :D :) What then they motivated to do?? ;-) Captcha is something that verify is this man or its robot. Your captcha if use Cookie just give user new task to recognize graphics :D and input they..  You code is super, but i think if you change just few lines it will be much more secured :)

P.S. This comment posted with Bot, And this not a  Joke! :)

# June 13, 2007 10:37 PM

Brendan Tompkins said:

Konviser,

Well, I can tell you that it does work quite well as is, and keeps us mainly spam free on CodeBetter.  No spammer has of yet been motivated to customize their bot to break this particular implementation (except for you of course).  

You're absolutely right though... session would be better, although it may not work in server farms.  I'll look at it and possibly make it a customization.

# June 14, 2007 9:14 AM

Mattias Berndtson said:

Its working fine for the blog post comment but how do i get i to work for the forum post?

I've added the following line in the default.browser  "<adapter controlType="CommunityServer.Discussions.Controls.CreateEditForumPostForm" adapterType="CodeBetter.CommunityServerExtensions.CaptchaControlAdapter, CodeBetter.CommunityServerExtensions" />" but nothing shows up?

# September 3, 2007 5:46 AM

Il Blog di Sandro Rizzetto said:

Con la scusa di dover testare questo captcha per CS2007 ho riaperto i commenti ( chiusi un paio di mesi

# September 30, 2007 5:48 AM

john said:

Hello,

I wanted this captcha component for our registration page on the createuser.aspx page.  I have followed the three steps to installing this captcha.  On the createuser.aspx page there is no ValidationGroup.  Now when i click on the register link all I see is the red x to indicate that the image is not there, the text "Enter the numbers above" and the text box to enter the numbers.  Can some please help me figure out what went wrong.

Thanks.

# October 11, 2007 6:02 PM

Brendan Tompkins said:

John,

Did you make the changes your web.config file as specified in the readme file?

# October 11, 2007 7:30 PM

john said:

Brendan,

Thank you for your reply.  If you are talking about adding the httphandlers section with the captcha.ashx then yes I have done that which I believe was step 3 on the instruction list.  Also I have made the changes from step 3 to the default.browser file.  Not sure what I did wrong?

# October 12, 2007 10:49 AM

Steve said:

Brendan, I installed your component and it works great.  Would it be possible to edit it to also work in the forums too?  It covers all my site except the forums.

# November 1, 2007 6:43 AM

darkthread said:

I met the same problem, the CAPTCHA doesn't show up in forum post editor.

After some study, I found the source code need to be modified for forum.  Here's the detail:

blog.darkthread.net/.../codebetter-captcha-modification.aspx

Thanks to Brendan, it's really fancy!

# November 10, 2007 11:11 AM

Sonu Kapoor said:

Great control. Thanks a lot Brendan.

# November 14, 2007 9:47 AM

jacob said:

sorry brendan, using a cookie to store the captcha code sucks.

and "probably not something that a spammer would be motivated to do.." would maybe be true of you had written your own proprietary system, but this being the best available captcha control for cs 2007 ... come on.

jacob

# November 30, 2007 6:39 AM

Brendan Tompkins said:

Jacob..

Yes, I agree.. It's a stupid solution, but it does work.  I've looked at the code and can't really figure out an elegant way to store it as a cookie. I can tell you that it does stop spam, and has been the only thing that works here at Codebetter.

When I can eek out a free moment, I'll try to come up with a better solution.

# November 30, 2007 9:11 AM

Brendan Tompkins [MVP] said:

Just a quick post to announce the release of the latest version of CodeBetter.CommunityServerExtensions

# December 5, 2007 11:51 AM

acid said:

its really helped me, thanks

# December 20, 2007 7:27 AM

testingcaptcha said:

JUST CHECKING TO SEE IF THIS CAPTCHA IS WORKING OR NOT BY MISTYPING THE CAPTCHA CODE. iF YOU READ THIS MEANS CAPTCHA FAILED

THANKS

# February 28, 2008 8:58 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Brendan Tompkins

Brendan has been programming with .NET since the first public beta and is owner and operator of Port Technology Services, a consultancy company providing .NET application development services to the Maritime industry. In July, 2007, he was awarded the Microsoft MVP award for ASP.NET. He's also a proud co-founder of failed .COM startup Intrinsigo, and has had a hand in the failure of numerous other businesses. He currently runs CodeBetter.Com and Devlicio.us, and lives in Norfolk, Virgina with his wife Tiara and son Ian.

View Brendan's profile on LinkedIn

Check out Devlicio.us!