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 cUser
.insert(name
, password
);
33 printError(ErrSysInternal
,
34 "Catalog table insert failed for the user %s",name
);
35 return ErrSysInternal
;
40 int UserManagerImpl::deleteUser(const char *name
)
44 printError(ErrNoPrivilege
,
45 "Only DBA privileged schema can delete users");
46 return ErrNoPrivilege
;
49 CatalogTableUSER
cUser(systemDatabase_
);
50 ret
= cUser
.remove(name
);
53 printError(ErrNotExists
,
54 "User %s not exists",name
);
60 int UserManagerImpl::changePassword(const char *usrName
, const char* newPasswd
)
64 printError(ErrNoPrivilege
,
65 "Only DBA privileged schema can change password for other users");
66 return ErrNoPrivilege
;
69 CatalogTableUSER
cUser(systemDatabase_
);
70 ret
= cUser
.changePass(usrName
, newPasswd
);
73 printError(ErrSysInternal
,
74 "Catalog table updation failed for user %s",usrName
);
75 return ErrSysInternal
;
81 int UserManagerImpl::changePassword(const char* newPasswd
)
84 CatalogTableUSER
cUser(systemDatabase_
);
85 ret
= cUser
.changePass(userName
, newPasswd
);
88 printError(ErrSysInternal
,
89 "Catalog table updation failed");
90 return ErrSysInternal
;