1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_connectivity.hxx"
26*b1cdbd2cSJim Jagielski #include "adabas/BUser.hxx"
27*b1cdbd2cSJim Jagielski #include "adabas/BGroups.hxx"
28*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbc/XRow.hpp>
29*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbc/XResultSet.hpp>
30*b1cdbd2cSJim Jagielski #include "adabas/BConnection.hxx"
31*b1cdbd2cSJim Jagielski #include "connectivity/dbtools.hxx"
32*b1cdbd2cSJim Jagielski #include "connectivity/dbexception.hxx"
33*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbcx/Privilege.hpp>
34*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
35*b1cdbd2cSJim Jagielski #include "resource/adabas_res.hrc"
36*b1cdbd2cSJim Jagielski
37*b1cdbd2cSJim Jagielski using namespace connectivity::adabas;
38*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno;
39*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::beans;
40*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::sdbcx;
41*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::sdbc;
42*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::container;
43*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::lang;
44*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
OAdabasUser(OAdabasConnection * _pConnection)45*b1cdbd2cSJim Jagielski OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection) : connectivity::sdbcx::OUser(sal_True)
46*b1cdbd2cSJim Jagielski ,m_pConnection(_pConnection)
47*b1cdbd2cSJim Jagielski {
48*b1cdbd2cSJim Jagielski construct();
49*b1cdbd2cSJim Jagielski }
50*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
OAdabasUser(OAdabasConnection * _pConnection,const::rtl::OUString & _Name)51*b1cdbd2cSJim Jagielski OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection,
52*b1cdbd2cSJim Jagielski const ::rtl::OUString& _Name
53*b1cdbd2cSJim Jagielski ) : connectivity::sdbcx::OUser(_Name,sal_True)
54*b1cdbd2cSJim Jagielski ,m_pConnection(_pConnection)
55*b1cdbd2cSJim Jagielski {
56*b1cdbd2cSJim Jagielski construct();
57*b1cdbd2cSJim Jagielski }
58*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
refreshGroups()59*b1cdbd2cSJim Jagielski void OAdabasUser::refreshGroups()
60*b1cdbd2cSJim Jagielski {
61*b1cdbd2cSJim Jagielski if(!m_pConnection)
62*b1cdbd2cSJim Jagielski return;
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski TStringVector aVector;
65*b1cdbd2cSJim Jagielski aVector.reserve(7); // we don't know the excatly count of users but this should fit the normal need
66*b1cdbd2cSJim Jagielski Reference< XStatement > xStmt = m_pConnection->createStatement( );
67*b1cdbd2cSJim Jagielski ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '");
68*b1cdbd2cSJim Jagielski aSql += getName( );
69*b1cdbd2cSJim Jagielski aSql += ::rtl::OUString::createFromAscii("'");
70*b1cdbd2cSJim Jagielski
71*b1cdbd2cSJim Jagielski Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
72*b1cdbd2cSJim Jagielski if(xResult.is())
73*b1cdbd2cSJim Jagielski {
74*b1cdbd2cSJim Jagielski Reference< XRow > xRow(xResult,UNO_QUERY);
75*b1cdbd2cSJim Jagielski while(xResult->next())
76*b1cdbd2cSJim Jagielski aVector.push_back(xRow->getString(1));
77*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xResult);
78*b1cdbd2cSJim Jagielski }
79*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xStmt);
80*b1cdbd2cSJim Jagielski
81*b1cdbd2cSJim Jagielski if(m_pGroups)
82*b1cdbd2cSJim Jagielski m_pGroups->reFill(aVector);
83*b1cdbd2cSJim Jagielski else
84*b1cdbd2cSJim Jagielski m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this);
85*b1cdbd2cSJim Jagielski }
86*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
OUserExtend(OAdabasConnection * _pConnection)87*b1cdbd2cSJim Jagielski OUserExtend::OUserExtend( OAdabasConnection* _pConnection) : OAdabasUser(_pConnection)
88*b1cdbd2cSJim Jagielski {
89*b1cdbd2cSJim Jagielski construct();
90*b1cdbd2cSJim Jagielski }
91*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
92*b1cdbd2cSJim Jagielski typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
construct()93*b1cdbd2cSJim Jagielski void OUserExtend::construct()
94*b1cdbd2cSJim Jagielski {
95*b1cdbd2cSJim Jagielski
96*b1cdbd2cSJim Jagielski registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
97*b1cdbd2cSJim Jagielski }
98*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
createArrayHelper() const99*b1cdbd2cSJim Jagielski cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
100*b1cdbd2cSJim Jagielski {
101*b1cdbd2cSJim Jagielski Sequence< Property > aProps;
102*b1cdbd2cSJim Jagielski describeProperties(aProps);
103*b1cdbd2cSJim Jagielski return new cppu::OPropertyArrayHelper(aProps);
104*b1cdbd2cSJim Jagielski }
105*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
getInfoHelper()106*b1cdbd2cSJim Jagielski cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
107*b1cdbd2cSJim Jagielski {
108*b1cdbd2cSJim Jagielski return *OUserExtend_PROP::getArrayHelper();
109*b1cdbd2cSJim Jagielski }
110*b1cdbd2cSJim Jagielski typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
111*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getPrivileges(const::rtl::OUString & objName,sal_Int32 objType)112*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL OAdabasUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
113*b1cdbd2cSJim Jagielski {
114*b1cdbd2cSJim Jagielski if ( objType != PrivilegeObject::TABLE )
115*b1cdbd2cSJim Jagielski return 0;
116*b1cdbd2cSJim Jagielski
117*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
118*b1cdbd2cSJim Jagielski checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
119*b1cdbd2cSJim Jagielski
120*b1cdbd2cSJim Jagielski sal_Int32 nRights,nRightsWithGrant;
121*b1cdbd2cSJim Jagielski getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
122*b1cdbd2cSJim Jagielski return nRights;
123*b1cdbd2cSJim Jagielski }
124*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getAnyTablePrivileges(const::rtl::OUString & objName,sal_Int32 & nRights,sal_Int32 & nRightsWithGrant)125*b1cdbd2cSJim Jagielski void OAdabasUser::getAnyTablePrivileges(const ::rtl::OUString& objName, sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski nRightsWithGrant = nRights = 0;
128*b1cdbd2cSJim Jagielski // first we need to create the sql stmt to select the privs
129*b1cdbd2cSJim Jagielski Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
130*b1cdbd2cSJim Jagielski ::rtl::OUString sCatalog,sSchema,sTable;
131*b1cdbd2cSJim Jagielski ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
132*b1cdbd2cSJim Jagielski Reference<XStatement> xStmt = m_pConnection->createStatement();
133*b1cdbd2cSJim Jagielski ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("SELECT REFTABLENAME,PRIVILEGES FROM DOMAIN.USR_USES_TAB WHERE REFOBJTYPE <> 'SYSTEM' AND DEFUSERNAME = '");
134*b1cdbd2cSJim Jagielski sSql += m_Name;
135*b1cdbd2cSJim Jagielski sSql += ::rtl::OUString::createFromAscii("' AND REFTABLENAME = '");
136*b1cdbd2cSJim Jagielski sSql += sTable;
137*b1cdbd2cSJim Jagielski sSql += ::rtl::OUString::createFromAscii("'");
138*b1cdbd2cSJim Jagielski if(xStmt.is())
139*b1cdbd2cSJim Jagielski {
140*b1cdbd2cSJim Jagielski Reference<XResultSet> xRes = xStmt->executeQuery(sSql);
141*b1cdbd2cSJim Jagielski if(xRes.is())
142*b1cdbd2cSJim Jagielski {
143*b1cdbd2cSJim Jagielski Reference<XRow> xRow(xRes,UNO_QUERY);
144*b1cdbd2cSJim Jagielski if(xRow.is() && xRes->next())
145*b1cdbd2cSJim Jagielski {
146*b1cdbd2cSJim Jagielski ::rtl::OUString sPrivs = xRow->getString(2);
147*b1cdbd2cSJim Jagielski
148*b1cdbd2cSJim Jagielski struct _priv_nam
149*b1cdbd2cSJim Jagielski {
150*b1cdbd2cSJim Jagielski const sal_Char* pAsciiName;
151*b1cdbd2cSJim Jagielski sal_Int32 nNumericValue;
152*b1cdbd2cSJim Jagielski } privileges[] =
153*b1cdbd2cSJim Jagielski {
154*b1cdbd2cSJim Jagielski { "INS", Privilege::INSERT },
155*b1cdbd2cSJim Jagielski { "DEL", Privilege::DELETE },
156*b1cdbd2cSJim Jagielski { "UPD", Privilege::UPDATE },
157*b1cdbd2cSJim Jagielski { "ALT", Privilege::ALTER },
158*b1cdbd2cSJim Jagielski { "SEL", Privilege::SELECT },
159*b1cdbd2cSJim Jagielski { "REF", Privilege::REFERENCE }
160*b1cdbd2cSJim Jagielski };
161*b1cdbd2cSJim Jagielski for ( size_t i = 0; i < sizeof( privileges ) / sizeof( privileges[0] ); ++i )
162*b1cdbd2cSJim Jagielski {
163*b1cdbd2cSJim Jagielski sal_Int32 nIndex = sPrivs.indexOf( ::rtl::OUString::createFromAscii( privileges[i].pAsciiName ) );
164*b1cdbd2cSJim Jagielski if ( nIndex == -1 )
165*b1cdbd2cSJim Jagielski continue;
166*b1cdbd2cSJim Jagielski
167*b1cdbd2cSJim Jagielski nRights |= privileges[i].nNumericValue;
168*b1cdbd2cSJim Jagielski if ( sPrivs.copy( nIndex + 2, 1 ).equalsAscii( "+" ) )
169*b1cdbd2cSJim Jagielski nRightsWithGrant |= privileges[i].nNumericValue;
170*b1cdbd2cSJim Jagielski }
171*b1cdbd2cSJim Jagielski }
172*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xRes);
173*b1cdbd2cSJim Jagielski }
174*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xStmt);
175*b1cdbd2cSJim Jagielski }
176*b1cdbd2cSJim Jagielski }
177*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
getGrantablePrivileges(const::rtl::OUString & objName,sal_Int32 objType)178*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL OAdabasUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
179*b1cdbd2cSJim Jagielski {
180*b1cdbd2cSJim Jagielski if ( objType != PrivilegeObject::TABLE )
181*b1cdbd2cSJim Jagielski return 0;
182*b1cdbd2cSJim Jagielski
183*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
184*b1cdbd2cSJim Jagielski checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
185*b1cdbd2cSJim Jagielski
186*b1cdbd2cSJim Jagielski sal_Int32 nRights,nRightsWithGrant;
187*b1cdbd2cSJim Jagielski getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
188*b1cdbd2cSJim Jagielski return nRightsWithGrant;
189*b1cdbd2cSJim Jagielski }
190*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
grantPrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)191*b1cdbd2cSJim Jagielski void SAL_CALL OAdabasUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
192*b1cdbd2cSJim Jagielski {
193*b1cdbd2cSJim Jagielski if ( objType != PrivilegeObject::TABLE )
194*b1cdbd2cSJim Jagielski m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_GRANTED,*this);
195*b1cdbd2cSJim Jagielski
196*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
197*b1cdbd2cSJim Jagielski ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
198*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
199*b1cdbd2cSJim Jagielski {
200*b1cdbd2cSJim Jagielski ::rtl::OUString sGrant;
201*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii("GRANT ");
202*b1cdbd2cSJim Jagielski sGrant += sPrivs;
203*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii(" ON ");
204*b1cdbd2cSJim Jagielski Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
205*b1cdbd2cSJim Jagielski sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
206*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii(" TO ");
207*b1cdbd2cSJim Jagielski sGrant += m_Name;
208*b1cdbd2cSJim Jagielski
209*b1cdbd2cSJim Jagielski Reference<XStatement> xStmt = m_pConnection->createStatement();
210*b1cdbd2cSJim Jagielski if(xStmt.is())
211*b1cdbd2cSJim Jagielski xStmt->execute(sGrant);
212*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xStmt);
213*b1cdbd2cSJim Jagielski }
214*b1cdbd2cSJim Jagielski }
215*b1cdbd2cSJim Jagielski // -------------------------------------------------------------------------
revokePrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)216*b1cdbd2cSJim Jagielski void SAL_CALL OAdabasUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
217*b1cdbd2cSJim Jagielski {
218*b1cdbd2cSJim Jagielski if ( objType != PrivilegeObject::TABLE )
219*b1cdbd2cSJim Jagielski m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_REVOKED,*this);
220*b1cdbd2cSJim Jagielski
221*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
222*b1cdbd2cSJim Jagielski checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
223*b1cdbd2cSJim Jagielski ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
224*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
225*b1cdbd2cSJim Jagielski {
226*b1cdbd2cSJim Jagielski ::rtl::OUString sGrant;
227*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
228*b1cdbd2cSJim Jagielski sGrant += sPrivs;
229*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii(" ON ");
230*b1cdbd2cSJim Jagielski Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
231*b1cdbd2cSJim Jagielski sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
232*b1cdbd2cSJim Jagielski sGrant += ::rtl::OUString::createFromAscii(" FROM ");
233*b1cdbd2cSJim Jagielski sGrant += m_Name;
234*b1cdbd2cSJim Jagielski
235*b1cdbd2cSJim Jagielski Reference<XStatement> xStmt = m_pConnection->createStatement();
236*b1cdbd2cSJim Jagielski if(xStmt.is())
237*b1cdbd2cSJim Jagielski xStmt->execute(sGrant);
238*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xStmt);
239*b1cdbd2cSJim Jagielski }
240*b1cdbd2cSJim Jagielski }
241*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
242*b1cdbd2cSJim Jagielski // XUser
changePassword(const::rtl::OUString & objPassword,const::rtl::OUString & newPassword)243*b1cdbd2cSJim Jagielski void SAL_CALL OAdabasUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
244*b1cdbd2cSJim Jagielski {
245*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
246*b1cdbd2cSJim Jagielski checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
247*b1cdbd2cSJim Jagielski ::rtl::OUString sAlterPwd;
248*b1cdbd2cSJim Jagielski sAlterPwd = ::rtl::OUString::createFromAscii("ALTER PASSWORD \"");
249*b1cdbd2cSJim Jagielski sAlterPwd += objPassword.toAsciiUpperCase();
250*b1cdbd2cSJim Jagielski sAlterPwd += ::rtl::OUString::createFromAscii("\" TO \"") ;
251*b1cdbd2cSJim Jagielski sAlterPwd += newPassword.toAsciiUpperCase();
252*b1cdbd2cSJim Jagielski sAlterPwd += ::rtl::OUString::createFromAscii("\"") ;
253*b1cdbd2cSJim Jagielski
254*b1cdbd2cSJim Jagielski sal_Bool bDisposeConnection = sal_False;
255*b1cdbd2cSJim Jagielski Reference<XConnection> xConnection = m_pConnection;
256*b1cdbd2cSJim Jagielski if(m_pConnection->getMetaData()->getUserName() != m_Name)
257*b1cdbd2cSJim Jagielski {
258*b1cdbd2cSJim Jagielski OAdabasConnection* pNewConnection = new OAdabasConnection(m_pConnection->getDriverHandle(),m_pConnection->getDriver());
259*b1cdbd2cSJim Jagielski xConnection = pNewConnection;
260*b1cdbd2cSJim Jagielski if(pNewConnection)
261*b1cdbd2cSJim Jagielski {
262*b1cdbd2cSJim Jagielski Sequence< PropertyValue> aSeq(2);
263*b1cdbd2cSJim Jagielski aSeq.getArray()[0].Name = ::rtl::OUString::createFromAscii("user") ;
264*b1cdbd2cSJim Jagielski aSeq.getArray()[0].Value <<= m_Name;
265*b1cdbd2cSJim Jagielski aSeq.getArray()[1].Name = ::rtl::OUString::createFromAscii("password") ;
266*b1cdbd2cSJim Jagielski aSeq.getArray()[1].Value <<= objPassword;
267*b1cdbd2cSJim Jagielski pNewConnection->Construct(m_pConnection->getMetaData()->getURL(),aSeq);
268*b1cdbd2cSJim Jagielski }
269*b1cdbd2cSJim Jagielski bDisposeConnection = sal_True;
270*b1cdbd2cSJim Jagielski }
271*b1cdbd2cSJim Jagielski if(xConnection.is())
272*b1cdbd2cSJim Jagielski {
273*b1cdbd2cSJim Jagielski Reference<XStatement> xStmt = xConnection->createStatement();
274*b1cdbd2cSJim Jagielski if(xStmt.is())
275*b1cdbd2cSJim Jagielski xStmt->execute(sAlterPwd);
276*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xStmt);
277*b1cdbd2cSJim Jagielski if(bDisposeConnection)
278*b1cdbd2cSJim Jagielski ::comphelper::disposeComponent(xConnection);
279*b1cdbd2cSJim Jagielski }
280*b1cdbd2cSJim Jagielski else
281*b1cdbd2cSJim Jagielski ::dbtools::throwFunctionSequenceException(*this);
282*b1cdbd2cSJim Jagielski }
283*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getPrivilegeString(sal_Int32 nRights) const284*b1cdbd2cSJim Jagielski ::rtl::OUString OAdabasUser::getPrivilegeString(sal_Int32 nRights) const
285*b1cdbd2cSJim Jagielski {
286*b1cdbd2cSJim Jagielski ::rtl::OUString sPrivs;
287*b1cdbd2cSJim Jagielski if((nRights & Privilege::INSERT) == Privilege::INSERT)
288*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("INSERT");
289*b1cdbd2cSJim Jagielski
290*b1cdbd2cSJim Jagielski if((nRights & Privilege::DELETE) == Privilege::DELETE)
291*b1cdbd2cSJim Jagielski {
292*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
293*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii(",");
294*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("DELETE");
295*b1cdbd2cSJim Jagielski }
296*b1cdbd2cSJim Jagielski
297*b1cdbd2cSJim Jagielski if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
298*b1cdbd2cSJim Jagielski {
299*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
300*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii(",");
301*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
302*b1cdbd2cSJim Jagielski }
303*b1cdbd2cSJim Jagielski
304*b1cdbd2cSJim Jagielski if((nRights & Privilege::ALTER) == Privilege::ALTER)
305*b1cdbd2cSJim Jagielski {
306*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
307*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii(",");
308*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("ALTER");
309*b1cdbd2cSJim Jagielski }
310*b1cdbd2cSJim Jagielski
311*b1cdbd2cSJim Jagielski if((nRights & Privilege::SELECT) == Privilege::SELECT)
312*b1cdbd2cSJim Jagielski {
313*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
314*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii(",");
315*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("SELECT");
316*b1cdbd2cSJim Jagielski }
317*b1cdbd2cSJim Jagielski
318*b1cdbd2cSJim Jagielski if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
319*b1cdbd2cSJim Jagielski {
320*b1cdbd2cSJim Jagielski if(sPrivs.getLength())
321*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii(",");
322*b1cdbd2cSJim Jagielski sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
323*b1cdbd2cSJim Jagielski }
324*b1cdbd2cSJim Jagielski
325*b1cdbd2cSJim Jagielski return sPrivs;
326*b1cdbd2cSJim Jagielski }
327*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
328*b1cdbd2cSJim Jagielski
329