1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
16 #include<UserManagerImpl.h>
17 #include<CatalogTables.h>
19 int UserManagerImpl::createUser(const char *name
, const char *password
)
23 printError(ErrNoPrivilege
,
24 "Only DBA privileged schema can create users");
25 return ErrNoPrivilege
;
28 //add entry to USER table
29 CatalogTableUSER
cUser(systemDatabase_
);
30 ret
= cUser
.insert(name
, password
);
33 printError(ErrSysInternal
,
34 "Catalog table insert failed for the user %s",name
);
35 return ErrSysInternal
;
37 logFine(Conf::logger
, "User Created %s" , name
);
41 int UserManagerImpl::deleteUser(const char *name
)
45 printError(ErrNoPrivilege
,
46 "Only DBA privileged schema can delete users");
47 return ErrNoPrivilege
;
50 CatalogTableUSER
cUser(systemDatabase_
);
51 ret
= cUser
.remove(name
);
54 printError(ErrNotExists
,
55 "User %s not exists",name
);
58 logFine(Conf::logger
, "User Deleted %s" , name
);
62 int UserManagerImpl::changePassword(const char *usrName
, const char* newPasswd
)
66 printError(ErrNoPrivilege,
67 "Only DBA privileged schema can change password for other users");
68 return ErrNoPrivilege;
71 CatalogTableUSER
cUser(systemDatabase_
);
72 ret
= cUser
.changePass(usrName
, newPasswd
);
75 printError(ErrSysInternal
,
76 "Catalog table updation failed for user %s",usrName
);
77 return ErrSysInternal
;
79 logFine(Conf::logger
, "Password changed for %s" ,usrName
);
84 int UserManagerImpl::changePassword(const char* newPasswd
)
87 CatalogTableUSER
cUser(systemDatabase_
);
88 ret
= cUser
.changePass(userName
, newPasswd
);
91 printError(ErrSysInternal
,
92 "Catalog table updation failed");
93 return ErrSysInternal
;
95 logFine(Conf::logger
, "Password changed for %s" ,userName
);
99 List
UserManagerImpl::getAllUserNames(int *retval
)
102 //to store the tuple pointer of the table
104 CatalogTableUSER
cUser(systemDatabase_
);
105 return cUser
.getUserList();