If doing a SQL call on the option is easier for you, than it would be one way to go; however, since you have the user's ID in the username, you could skip that step (I'll use the user-option way, since it fits my plugin better).
Essentially, you'll need to add code to userExists() to check to see if that user has already been created, and either send an error message, or call the rename script.
I don't believe you would need to change the rename user special page to replace the ID, since it is supposed to be unique. If your ID is not unique, then you are probably going to start running into problems ;).
Notice that the function you mentioned returns the user's mediawiki ID. It probably won't help you too much. You should look at how mediawiki pulls options instead.
If you aren't a developer, these changes may be hard for you. Especially since this may (probably will...) require either a new hook, or logic changes in the core code.
I'll be implementing this functionality in the future to my plugin, so I may be doing some of the work for you. This isn't on my plate for my next release, and I haven't had much time for changes lately, so don't expect this to happen soon.
V/r,
Ryan Lane
-----Original Message----- From: mediawiki-l-bounces@Wikimedia.org [mailto:mediawiki-l- bounces@Wikimedia.org] On Behalf Of Brian Carpenter Sent: Thursday, May 04, 2006 1:20 PM To: MediaWiki announcements and site admin list Subject: Re: [Mediawiki-l] Best strategy to populate User data from Single Sign On?
Too much for a novice like me to grasp and run with it alone... If I understand correctly, your proposed method would create an option in the $userclass and set it to the employee's ID. I would then need to create a statement to check if that value exists for any other $user prior to new user creation. Sounds good. I just don't have the peices. Would I then also have to modify Specials:Renameuser to replace the $user(uniqueSSOID)optional value during rename?
While scavaging in user.php, I found a query snippet that checks if a user with the given name exists, then returns the ID.
function idForName() { $fname = 'User::idForName'; $gotid = 0; $s = trim( $this->getName() ); if ( 0 == strcmp( '', $s ) ) return 0; $dbr =& wfGetDB( DB_SLAVE ); $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), $fname ); if ( $id === false ) { $id = 0; } return $id; }
How could the above be copied/modified to return the full username ($username) that contains the string ($UniqueSSOid) of the about-to-be created user? I''m not a developer, but if I get help with the above, I can figure out how to alter the Autologin script to:
- halt auto new user creation and display a html informative message/page
to the browser. 2) send wgEmergencyContact email with existing and proposed usernames.
As for actually renaming the user: If I get this far, I would be very happy to perform the Special:Renameuser process manually... ... Until I learn more php
Thx again, Brian
This thread is also related to: http://mail.wikipedia.org/pipermail/mediawiki-l/2006-May/011779.html
On 5/4/06, Lane, Ryan laner@navo.navy.mil wrote:
Now if I can just create a method to determin if the user exists prior
to
new user creation - detailed in: http://mail.wikipedia.org/pipermail/mediawiki-l/2006-May/011779.html Thanks again, Brian
You could add the user's ID as a user option on user creation:
$user->setOption('uniqueSSOID',$yourUniqueSSOID);
in function initUser() in the authentication plugin you are using. If
you
do that, you can search the database based upon the ID.
I'm not sure if the core code currently has any hooks that would allow
you
to rename the user when the user logs in, without reporting errors...
I'm glad you brought this up, because I really didn't think about this, and this is definitely something I'll run into in the future. I'll have to look into adding support for this in my plugin.
V/r, Ryan Lane Lane@Wikimedia.org
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Ryan, Just to confirm, you wrote :
Essentially, you'll need to add code to userExists() to check to see if
that
user has already been created, and either send an error message, or call
the
rename script.
According to the author of my AutoLogin script, "Several routines from AuthPlugin must be overridden for correct operation to occur.... ...*userExists()* must return *true* always. The method is misleading. It's only called by MediaWiki in determining whether the user exists in the security context, not whether the user is in the MediaWiki database. " cite http://meta.wikimedia.org/wiki/User:Otheus/Auto_Login_via_REMOTE_USER
Am I missing something, or is these statements conflicting?
Should I place the test for 'does string exist in any username' in userExists() to prevent a new username initialization/creation?
Thx Brian
On 5/4/06, Lane, Ryan laner@navo.navy.mil wrote:
If doing a SQL call on the option is easier for you, than it would be one way to go; however, since you have the user's ID in the username, you could skip that step (I'll use the user-option way, since it fits my plugin better).
Essentially, you'll need to add code to userExists() to check to see if that user has already been created, and either send an error message, or call the rename script.
I don't believe you would need to change the rename user special page to replace the ID, since it is supposed to be unique. If your ID is not unique, then you are probably going to start running into problems ;).
Notice that the function you mentioned returns the user's mediawiki ID. It probably won't help you too much. You should look at how mediawiki pulls options instead.
If you aren't a developer, these changes may be hard for you. Especially since this may (probably will...) require either a new hook, or logic changes in the core code.
I'll be implementing this functionality in the future to my plugin, so I may be doing some of the work for you. This isn't on my plate for my next release, and I haven't had much time for changes lately, so don't expect this to happen soon.
V/r,
Ryan Lane
-----Original Message----- From: mediawiki-l-bounces@Wikimedia.org [mailto:mediawiki-l- bounces@Wikimedia.org] On Behalf Of Brian Carpenter Sent: Thursday, May 04, 2006 1:20 PM To: MediaWiki announcements and site admin list Subject: Re: [Mediawiki-l] Best strategy to populate User data from
Single
Sign On?
Too much for a novice like me to grasp and run with it alone... If I understand correctly, your proposed method would create an option
in
the $userclass and set it to the employee's ID. I would then need to create a statement to check if that value exists for any other $user prior to
new
user creation. Sounds good. I just don't have the peices. Would I then also have to modify Specials:Renameuser to replace the $user(uniqueSSOID)optional value during rename?
While scavaging in user.php, I found a query snippet that checks if a
user
with the given name exists, then returns the ID.
function idForName() { $fname = 'User::idForName'; $gotid = 0; $s = trim( $this->getName() ); if ( 0 == strcmp( '', $s ) ) return 0; $dbr =& wfGetDB( DB_SLAVE ); $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s
),
$fname ); if ( $id === false ) { $id = 0; } return $id; }
How could the above be copied/modified to return the full username ($username) that contains the string ($UniqueSSOid)
of the
about-to-be created user? I''m not a developer, but if I get help with the above, I can figure
out
how to alter the Autologin script to:
- halt auto new user creation and display a html informative
message/page
to the browser. 2) send wgEmergencyContact email with existing and proposed usernames.
As for actually renaming the user: If I get this far, I would be very happy to perform the Special:Renameuser process manually... ... Until I learn more php
Thx again, Brian
This thread is also related to: http://mail.wikipedia.org/pipermail/mediawiki-l/2006-May/011779.html
On 5/4/06, Lane, Ryan laner@navo.navy.mil wrote:
Now if I can just create a method to determin if the user exists
prior
to
new user creation - detailed in: http://mail.wikipedia.org/pipermail/mediawiki-l/2006-May/011779.html Thanks again, Brian
You could add the user's ID as a user option on user creation:
$user->setOption('uniqueSSOID',$yourUniqueSSOID);
in function initUser() in the authentication plugin you are using. If
you
do that, you can search the database based upon the ID.
I'm not sure if the core code currently has any hooks that would allow
you
to rename the user when the user logs in, without reporting errors...
I'm glad you brought this up, because I really didn't think about
this,
and this is definitely something I'll run into in the future. I'll have to look into adding support for this in my plugin.
V/r, Ryan Lane Lane@Wikimedia.org
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org