SetLoginName

Description

Changes the login name of the current user. Can also change the password of the current user if a value is specified.

Note: Neither argument is optional. If a new login name and a blank (null) password are supplied, the login name changes while leaving the existing password unchanged. If you specify a value for the password parameter, then the value you specify becomes the new password. If you leave out the login name parameter, a type mismatch error is returned.
Note:

This method can be used to support MultiSite operations, as it can be used to resolve ambiguous names.

To detect whether there are multiple users with the same name on other sites, you can use the GetDisplayNamesNeedingSiteExtension method in Session. For example, a user named "Tom" might have been created on more than one site.

There is no return value. Changes will take effect at the next login.

Syntax

VBScript

user.SetLoginName new_name, new_password 

Perl

user->SetLoginName(new_name, new_password); 
Identifier
Description
user
A User object.
new_name
A String containing a new or existing user name.
new_password
A String containing a new password.
Return value
None.

Example

Perl

# change a user login name and password using SetLoginName

use CQPerlExt;

my $adminSession = CQAdminSession::Build();

   ($newusername, $newpasswd, $cqdb) = @ARGV;

   $adminUser = "admin";

   $adminPasswd = "";

   $adminSession->Logon($adminUser, $adminPasswd, ""); 

   $userobj = $adminSession->GetUser($user);

   $userobj->SetLoginName($newusername, $newpasswd);

   $dbobj= $adminSession->GetDatabase($cqdb);

   $dbobj->UpgradeMasterUserInfo();

CQAdminSession::Unbuild($adminSession); 


Feedback