Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29820/win32/src
Modified Files:
win32security_sspi.cpp
Log Message:
Make directory services handle a subtype of PyHANDLE so it can call DsUnBind on destruction
Index: win32security_sspi.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security_sspi.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32security_sspi.cpp 8 Mar 2005 13:13:03 -0000 1.2
--- win32security_sspi.cpp 9 Mar 2005 10:23:42 -0000 1.3
***************
*** 1216,1219 ****
--- 1216,1249 ----
}
+ // Directory service handle, yet another type of PyHANDLE
+ // @object PyDS_HANDLE|Directory service handle, returned by <om win32security.DsBind>
+ // Subtype of <o PyHANDLE>, inherits all properties and methods
+ class PyDS_HANDLE: public PyHANDLE
+ {
+ public:
+ PyDS_HANDLE(HANDLE hInit) : PyHANDLE(hInit) {}
+ virtual BOOL Close(void) {
+ DWORD err;
+ if (!m_handle)
+ return TRUE; // already closed or Detached, nothing to do
+ if (pfnDsUnBind==NULL){
+ // should not happen if functions to create a Ds handle exist ...
+ PyErr_SetString(PyExc_SystemError,"Error closing PyDS_HANDLE, DsUnBind is NULL");
+ return FALSE;
+ }
+ err = (*pfnDsUnBind)(&m_handle);
+ // ??? This function apparently never returns an error, no matter what you pass to it ???
+ if (err==NO_ERROR){
+ m_handle = 0;
+ return TRUE;
+ }
+ PyWin_SetAPIError("PyDS_HANDLE::Close", err);
+ return FALSE;
+ }
+ virtual const char *GetTypeName(){
+ return "PyDS_HANDLE";
+ }
+ };
+
// directory service functions for registering target Spns to be used with Kerberos
extern PyObject *PyDsBind(PyObject *self, PyObject *args)
***************
*** 1232,1236 ****
err=(*pfnDsBind)(dc, domain, &dshandle);
if (err==NO_ERROR)
! ret=PyWinObject_FromHANDLE(dshandle);
else
PyWin_SetAPIError("DsBind",err);
--- 1262,1266 ----
err=(*pfnDsBind)(dc, domain, &dshandle);
if (err==NO_ERROR)
! ret=new PyDS_HANDLE(dshandle);
else
PyWin_SetAPIError("DsBind",err);
|