I installed TWiki on an intranet that authorizes users against an LDAP server. I wanted TWiki to force them into registering before using the system (upon first login).
I stumbled across this support request that asked for the same thing:
RecognisedButUnregisteredUsers
It may be possible to do this as a plugin (using the initialize1 or initialize2 hook), but I have not had time to learn how the plugin structure works.
I added the following code in TWiki.pm, right after line 445 (in initialization where the wikiName and wikiUserName variables are set):
# Make sure the user has a topic, if not - send to registration to make one
# jeff hedlund 6-30-04
if (!TWiki::Store::topicExists( $mainWebname, $wikiName ) and
$theUrl !~ m!$scriptUrlPath/oops! and
$topicName !~ m!TWikiRegistration!) {
my $url = &TWiki::getOopsUrl( $webName, $topicName, "oopsnotwikiuser" );
print $cgiQuery->redirect( $url );
return;
}
This allows only the oops and
TWikiRegistration pages to be shown. So when the user first logs into the system, they will be taken to the oopsnotwikiuser template page.
I modified the oopsnotwikiuser template page to point to
TWikiRegistration so that they could then register.
--
JeffHedlund - 30 Jun 2004
This patch broke the
mailnotify script; it complained about the use of an uninitialised value.
I fixed it with this change:
if ($wikiName and $wikiName ne "nobody" and
!TWiki::Store::topicExists( $mainWebname, $wikiName ) and
$theUrl !~ m!$scriptUrlPath/oops! and
$topicName !~ m!TWikiRegistration!) {
my $url = &TWiki::getOopsUrl( $webName, $topicName, "oopsnotwikiuser" )\
;
print $cgiQuery->redirect($url);
return;
}
I guess you could create a NobodyUser and map this to login "nobody" on
TWikiUsers to do the same job.
If your view script is not authenticated, you also need to take care that the
TWikiGuest page still exist on your system (I had removed it) and that user
"guest" is mapped to
TWikiGuest in
TWikiUsers. If you don't, no-one will be able to view content withoug logging in.
--
GarethEdwards - 05 Dec 2004
This is a good idea, and it does belong in a plugin. There really should a
WantedPlugins page... or, better yet, ActionTrackerPlugin installed here.
--
MartinCleaver - 05 Dec 2004
I'll consider taking on the development of this feature as a plugin; it's about time I tried to develop one. Once I get the last anomalies thrashed out of my upgrade to
CairoRelease I'll start it as a lunchtime project.
--
GarethEdwards - 06 Dec 2004
There is no doubt that since TWiki is targeted at intranet enviornments, a Plugin for authenticating users against LDAP or other such systems would be of great use.
--
GauravSharma - 09 Mar 2006
Yes, I second Gaurav's motion! We need
TransparentRegistration!
--
AndrewBanks - 02 Jun 2006
I just recently upgraded to 4.1.1 from a 2004 version and had to reimplement this. What worked for my situation was modifying the View.pm module. There may be some fallibility in only modifying the view script and not the others, but it works for my situation: Our entire site requires LDAP authentication - once the Apache accepts the username/password - the person attempting to view any page will make sure they have registered and if not, send the user to the not registered page as before.
In the "view" sub of View.pm, I added the following code:
Line 81 in the unmodified code:
TWiki::UI::checKWebExists( $session, $webName, $topicName, 'view');
After that, I added:
my $user = $session->{users}->findUser($session->{user}->login);
if(!store->topicExists($user->web(), $user->wikiName()) &&
$topicName !~ m!TWikiRegistration!) {
throw TWiki::OopsException( 'notwikiuser',
def => 'notwikiuser',
web => $webName,
topic => $topicName,
params => $user->webDotWikiName());
}
Then as my original post suggested, I modified the oopsnotwikiuser template and the
TWikiRegistration.
--
JeffHedlund - 27 Feb 2007