src/server/UserManagerImpl.cxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015   ***************************************************************************/
00016 #include<UserManagerImpl.h>
00017 #include<CatalogTables.h>
00018 #include<Debug.h>
00019 int UserManagerImpl::createUser(const char *name, const char *password)
00020 {
00021     if (!isDba)
00022     {
00023         printError(ErrNoPrivilege,
00024                    "Only DBA privileged schema can create users");
00025         return ErrNoPrivilege;
00026     }
00027     int ret = 0;
00028     //add entry to USER table
00029     CatalogTableUSER cUser(systemDatabase_);
00030     cUser.insert(name, password);
00031     if (0 != ret)
00032     {
00033         printError(ErrSysInternal,
00034                    "Catalog table insert failed for the user %s",name);
00035         return ErrSysInternal;
00036     }
00037     return OK;
00038 }
00039 
00040 int UserManagerImpl::deleteUser(const char *name)
00041 {
00042     if (!isDba)
00043     {
00044         printError(ErrNoPrivilege,
00045                    "Only DBA privileged schema can delete users");
00046         return ErrNoPrivilege;
00047     }
00048     int ret = 0;
00049     CatalogTableUSER cUser(systemDatabase_);
00050     ret = cUser.remove(name);
00051     if (0 != ret)
00052     {
00053         printError(ErrNotExists,
00054                            "User %s not exists",name);
00055         return ErrNotExists;
00056     }
00057     return OK;
00058 }
00059 
00060 int UserManagerImpl::changePassword(const char *usrName, const char* newPasswd)
00061 {
00062     if (!isDba)
00063     {
00064         printError(ErrNoPrivilege,
00065                    "Only DBA privileged schema can change password for other users");
00066         return ErrNoPrivilege;
00067     }
00068     int ret = 0;
00069     CatalogTableUSER cUser(systemDatabase_);
00070     ret = cUser.changePass(usrName, newPasswd );
00071     if (0 != ret)
00072     {
00073         printError(ErrSysInternal,
00074                    "Catalog table updation failed for user %s",usrName);
00075         return ErrSysInternal;
00076     }
00077     return OK;
00078 }
00079 
00080 
00081 int UserManagerImpl::changePassword(const char* newPasswd)
00082 {
00083     int ret = 0;
00084     CatalogTableUSER cUser(systemDatabase_);
00085     ret = cUser.changePass(userName, newPasswd );
00086     if (0 != ret)
00087     {
00088         printError(ErrSysInternal,
00089                    "Catalog table updation failed");
00090         return ErrSysInternal;
00091     }
00092     return OK;
00093 }

Generated on Mon Jun 9 22:37:15 2008 for csql by  doxygen 1.4.7