pywin32-checkins Mailing List for Python for Windows Extensions (Page 113)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2005-05-24 14:45:12
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28437 Modified Files: PythonCOM.cpp Log Message: Add CoWaitForMultipleHandles Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** PythonCOM.cpp 7 Jan 2005 06:54:56 -0000 1.34 --- PythonCOM.cpp 24 May 2005 14:45:01 -0000 1.35 *************** *** 73,76 **** --- 73,84 ---- extern LONG _PyCom_GetGatewayCount(void); + // Function pointers we load at runtime. + HRESULT (STDAPICALLTYPE *pfnCoWaitForMultipleHandles)(DWORD dwFlags, + DWORD dwTimeout, + ULONG cHandles, + LPHANDLE pHandles, + LPDWORD lpdwindex + ) = NULL; + BOOL PyCom_HasDCom() *************** *** 211,215 **** // Jump hoops in case the platform doesnt have it. { // scoping ! HRESULT (*mypfn)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod==0) { --- 219,223 ---- // Jump hoops in case the platform doesnt have it. { // scoping ! HRESULT (STDAPICALLTYPE *mypfn)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod==0) { *************** *** 222,226 **** goto done; } ! mypfn = (HRESULT (*)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *))fp; PY_INTERFACE_PRECALL; HRESULT hr = (*mypfn)(clsid, punk, dwClsContext, pServerInfo, numIIDs, mqi); --- 230,234 ---- goto done; } ! mypfn = (HRESULT (STDAPICALLTYPE *)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *))fp; PY_INTERFACE_PRECALL; HRESULT hr = (*mypfn)(clsid, punk, dwClsContext, pServerInfo, numIIDs, mqi); *************** *** 1311,1314 **** --- 1319,1386 ---- } + static BOOL MakeHandleList(PyObject *handleList, HANDLE **ppBuf, DWORD *pNumEntries) + { + if (!PySequence_Check(handleList)) { + PyErr_SetString(PyExc_TypeError, "Handles must be a list of integers"); + return FALSE; + } + DWORD numItems = (DWORD)PySequence_Length(handleList); + HANDLE *pItems = (HANDLE *)malloc(sizeof(HANDLE) * numItems); + if (pItems==NULL) { + PyErr_SetString(PyExc_MemoryError,"Allocating array of handles"); + return FALSE; + } + for (DWORD i=0;i<numItems;i++) { + PyObject *obItem = PySequence_GetItem(handleList, i); + if (obItem==NULL) { + free(pItems); + return FALSE; + } + if (!PyWinObject_AsHANDLE(obItem,pItems+i)) { + Py_DECREF(obItem); + free(pItems); + PyErr_SetString(PyExc_TypeError, "Handles must be a list of integers"); + return FALSE; + } + Py_DECREF(obItem); + } + *ppBuf = pItems; + *pNumEntries = numItems; + return TRUE; + } + + // @pymethod int|pythoncom|CoWaitForMultipleHandles|Waits for specified handles to be signaled or for a specified timeout period to elapse. + static PyObject *pythoncom_CoWaitForMultipleHandles(PyObject *self, PyObject *args) + { + DWORD flags, timeout; + PyObject *obHandles; + DWORD numItems; + HANDLE *pItems = NULL; + if (!pfnCoWaitForMultipleHandles) { + return PyCom_BuildPyException(E_NOTIMPL); + return NULL; + } + + if (!PyArg_ParseTuple(args, "iiO:CoWaitForMultipleHandles", + &flags, // @pyparm int|flags|| + &timeout, // @pyparm int|timeout|| + &obHandles)) // @pyparm [<o PyHANDLE>, ...]|handles|| + return NULL; + if (!MakeHandleList(obHandles, &pItems, &numItems)) + return NULL; + DWORD index; + PyObject *rc = NULL; + HRESULT hr; + Py_BEGIN_ALLOW_THREADS + hr = (*pfnCoWaitForMultipleHandles)(flags, timeout, numItems, pItems, &index); + Py_END_ALLOW_THREADS + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + } else + rc = PyInt_FromLong(index); + free(pItems); + return rc; + } + // @pymethod <o PyIDataObject>|pythoncom|OleGetClipboard|Retrieves a data object that you can use to access the contents of the clipboard. static PyObject *pythoncom_OleGetClipboard(PyObject *, PyObject *args) *************** *** 1511,1514 **** --- 1583,1587 ---- { "CoRevokeClassObject",pythoncom_CoRevokeClassObject, 1 },// @pymeth CoRevokeClassObject|Informs OLE that a class object, previously registered with the <om pythoncom.CoRegisterClassObject> method, is no longer available for use. { "CoTreatAsClass", pythoncom_CoTreatAsClass, 1}, // @pymeth CoTreatAsClass|Establishes or removes an emulation, in which objects of one class are treated as objects of a different class. + { "CoWaitForMultipleHandles", pythoncom_CoWaitForMultipleHandles, 1}, // @pymeth CoWaitForMultipleHandles|Waits for specified handles to be signaled or for a specified timeout period to elapse. { "Connect", pythoncom_connect, 1 }, // @pymeth Connect|Connects to a running instance of an OLE automation server. { "connect", pythoncom_connect, 1 }, *************** *** 1696,1699 **** --- 1769,1778 ---- PyDict_SetItemString(dict, "PyUnicodeType", (PyObject *)&PyUnicodeType); + // Load function pointers. + HMODULE hModOle32 = GetModuleHandle("ole32.dll"); + pfnCoWaitForMultipleHandles = \ + (HRESULT (STDAPICALLTYPE *)(DWORD, DWORD, ULONG, LPHANDLE, LPDWORD)) \ + GetProcAddress(hModOle32, "CoWaitForMultipleHandles"); + // Symbolic constants. ADD_CONSTANT(ACTIVEOBJECT_STRONG); |
From: Mark H. <mha...@us...> - 2005-05-24 14:30:14
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25170 Modified Files: __init__.py Log Message: In some cases, GetTypeInfo will return an AttributeError. Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** __init__.py 4 Mar 2005 23:49:56 -0000 1.33 --- __init__.py 24 May 2005 14:30:04 -0000 1.34 *************** *** 30,34 **** if typeinfo is not None: # Some objects return NULL, some raise exceptions... resultCLSID = str(typeinfo.GetTypeAttr()[0]) ! except pythoncom.com_error: pass if resultCLSID is not None: --- 30,34 ---- if typeinfo is not None: # Some objects return NULL, some raise exceptions... resultCLSID = str(typeinfo.GetTypeAttr()[0]) ! except (pythoncom.com_error, AttributeError): pass if resultCLSID is not None: |
From: Mark H. <mha...@us...> - 2005-05-24 14:10:52
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20743 Modified Files: pywin32.mak Log Message: add PyIDirectorySearch.i to the docs. Index: pywin32.mak =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/pywin32.mak,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pywin32.mak 12 Apr 2005 06:17:53 -0000 1.11 --- pywin32.mak 24 May 2005 14:10:41 -0000 1.12 *************** *** 81,84 **** --- 81,85 ---- $(GENDIR)\PyIADsUser.d \ $(GENDIR)\PyIDirectoryObject.d \ + $(GENDIR)\PyIDirectorySearch.d \ PYTHONWIN_SOURCE = \ *************** *** 230,233 **** --- 231,237 ---- $(PYTHON) makedfromi.py -o$*.d $(ADSI_DIR)/src/$(*B).i + $(GENDIR)\PyIDirectorySearch.d: $(ADSI_DIR)/src/$(*B).i + $(PYTHON) makedfromi.py -o$*.d $(ADSI_DIR)/src/$(*B).i + !include "common.mak" |
From: Mark H. <mha...@us...> - 2005-05-24 13:55:41
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17051/win32/src Modified Files: win32security.i win32security_sspi.cpp win32security_sspi.h Added Files: win32security_ds.cpp Log Message: * setup.py now allows sources to be specified; win32security and win32net now do so, making their .dsp files redundant. * Existing win32security Ds* (DirectoryService) functions (not to be confused with the COM related win32com.adsi module!) split into new win32security_ds.cpp module. * New win32security functions TranslateName, DsGetDcName and DsCrackNames * Release the GIL when calling SSPI and DS functions. * New Ds related constants in ntsecuritycon. * New tests for these functions. --- NEW FILE: win32security_ds.cpp --- #include "PyWinTypes.h" #include "structmember.h" #include "PyWinObjects.h" #include "PySecurityObjects.h" #include "win32security_sspi.h" #include "Lm.h" // for NetApiBufferFree, for some Ds functions. // 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) { WCHAR *dc=NULL, *domain=NULL; PyObject *obdc=Py_None, *obdomain=Py_None; PyObject *ret=NULL; DWORD err; HANDLE dshandle; CHECK_PFN(DsBind); if (!PyArg_ParseTuple(args, "|OO:DsBind", obdc, obdomain)) return NULL; if (PyWinObject_AsWCHAR(obdc, &dc, TRUE) && PyWinObject_AsWCHAR(obdomain, &domain, TRUE)){ err=(*pfnDsBind)(dc, domain, &dshandle); if (err==NO_ERROR) ret=new PyDS_HANDLE(dshandle); else PyWin_SetAPIError("DsBind",err); } PyWinObject_FreeWCHAR(dc); PyWinObject_FreeWCHAR(domain); return ret; } extern PyObject *PyDsUnBind(PyObject *self, PyObject *args) { DWORD err; HANDLE dshandle; PyObject *obhandle; CHECK_PFN(DsUnBind); if (!PyArg_ParseTuple(args, "O:DsUnBind", &obhandle)) return NULL; if (!PyWinObject_AsHANDLE(obhandle, &dshandle)) return NULL; Py_BEGIN_ALLOW_THREADS err=(*pfnDsUnBind)(&dshandle); Py_END_ALLOW_THREADS if (err==NO_ERROR){ Py_INCREF(Py_None); return Py_None; } PyWin_SetAPIError("DsUnBind",err); return NULL; } void PyWinObject_FreeWCHARArray(LPWSTR *wchars, DWORD str_cnt) { if (wchars!=NULL){ for (DWORD wchar_index=0; wchar_index<str_cnt; wchar_index++) PyWinObject_FreeWCHAR(wchars[wchar_index]); free(wchars); } } BOOL PyWinObject_AsWCHARArray(PyObject *str_seq, LPWSTR **wchars, DWORD *str_cnt) { BOOL ret=FALSE; PyObject *str_tuple=NULL, *tuple_item; DWORD bufsize, tuple_index; *wchars=NULL; *str_cnt=0; if ((str_tuple=PySequence_Tuple(str_seq))==NULL) return FALSE; *str_cnt=PyTuple_Size(str_tuple); bufsize=*str_cnt * sizeof(LPWSTR); *wchars=(LPWSTR *)malloc(bufsize); if (*wchars==NULL){ PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); goto done; } ZeroMemory(*wchars, bufsize); for (tuple_index=0;tuple_index<*str_cnt;tuple_index++){ tuple_item=PyTuple_GET_ITEM(str_tuple, tuple_index); if (!PyWinObject_AsWCHAR(tuple_item, &((*wchars)[tuple_index]), FALSE)){ PyWinObject_FreeWCHARArray(*wchars, *str_cnt); *wchars=NULL; *str_cnt=0; goto done; } } ret=TRUE; done: Py_XDECREF(str_tuple); return ret; } extern PyObject *PyDsGetSpn(PyObject *self, PyObject *args) { DWORD err, cSpns, bufsize, name_cnt; DS_SPN_NAME_TYPE ServiceType; WCHAR *ServiceClass=NULL, *ServiceName=NULL; PyObject *obServiceClass, *obServiceName; PyObject *ret=NULL, *tuple_item; LPWSTR *Spns=NULL, *InstanceNames=NULL; USHORT tuple_index, InstancePort=0, cInstanceNames=0, *InstancePorts=NULL; long port_nbr; PyObject *obInstanceNames=Py_None, *obInstancePorts=Py_None; PyObject *obInstancePorts_tuple=NULL; CHECK_PFN(DsGetSpn); CHECK_PFN(DsFreeSpnArray); if (!PyArg_ParseTuple(args,"lOO|HOO:DsGetSpn", &ServiceType, &obServiceClass, &obServiceName, &InstancePort, &obInstanceNames, &obInstancePorts)) return NULL; if (!PyWinObject_AsWCHAR(obServiceClass, &ServiceClass, FALSE)) goto done; if (!PyWinObject_AsWCHAR(obServiceName, &ServiceName, TRUE)) goto done; if (obInstanceNames!=Py_None){ if (!PyWinObject_AsWCHARArray(obInstanceNames, &InstanceNames, &name_cnt)) goto done; if (name_cnt>USHRT_MAX){ PyErr_Format(PyExc_ValueError, "Count of InstanceNames cannot exceed %d", USHRT_MAX); goto done; } cInstanceNames=(USHORT)name_cnt; } if (obInstancePorts!=Py_None){ if ((obInstancePorts_tuple=PySequence_Tuple(obInstancePorts))==NULL) goto done; if (PyTuple_Size(obInstancePorts_tuple)!=cInstanceNames){ PyErr_SetString(PyExc_ValueError,"DsGetSpn: InstancePorts must be same size sequence as InstanceNames"); goto done; } bufsize=cInstanceNames * sizeof(USHORT); InstancePorts=(USHORT *)malloc(bufsize); if (InstancePorts==NULL){ PyErr_Format(PyExc_MemoryError, "DsGetSpn: Unable to allocate %d bytes", bufsize); goto done; } for (tuple_index=0;tuple_index<cInstanceNames;tuple_index++){ tuple_item=PyTuple_GET_ITEM(obInstancePorts_tuple,tuple_index); // convert a python int to a USHORT // ??? any API function to do this other than H format of PyArg_ParseTuple ??? port_nbr=PyInt_AsLong(tuple_item); if ((port_nbr==(unsigned long)-1 && PyErr_Occurred()) || (port_nbr<0)){ PyErr_Clear(); PyErr_Format(PyExc_TypeError,"InstancePorts must be a sequence of ints in the range 0-%d",USHRT_MAX); goto done; } if (port_nbr > USHRT_MAX){ PyErr_Format(PyExc_ValueError, "InstancePorts values cannot exceed %d", USHRT_MAX); goto done; } InstancePorts[tuple_index]=(USHORT)port_nbr; } } Py_BEGIN_ALLOW_THREADS err=(*pfnDsGetSpn)(ServiceType, ServiceClass, ServiceName, InstancePort, cInstanceNames, (LPCWSTR *)InstanceNames, InstancePorts, &cSpns, &Spns); Py_END_ALLOW_THREADS if (err!=STATUS_SUCCESS) PyWin_SetAPIError("DsGetSpn",err); else{ ret=PyTuple_New(cSpns); if (ret!=NULL){ for (tuple_index=0;tuple_index<cSpns;tuple_index++){ tuple_item=PyWinObject_FromWCHAR(Spns[tuple_index]); if (tuple_item==NULL){ Py_DECREF(ret); ret=NULL; break; } PyTuple_SET_ITEM(ret, tuple_index, tuple_item); } } } done: if (Spns!=NULL) (*pfnDsFreeSpnArray)(cSpns, Spns); PyWinObject_FreeWCHARArray(InstanceNames, cInstanceNames); if (InstancePorts!=NULL) free(InstancePorts); if (obInstancePorts_tuple!=NULL) Py_DECREF(obInstancePorts_tuple); PyWinObject_FreeWCHAR(ServiceClass); PyWinObject_FreeWCHAR(ServiceName); return ret; } extern PyObject *PyDsWriteAccountSpn(PyObject *self, PyObject *args) { DWORD err, spn_cnt; HANDLE dshandle; DS_SPN_WRITE_OP Operation; LPWSTR acct, *spns=NULL; PyObject *ret=NULL, *obhandle, *obacct, *obspns; CHECK_PFN(DsWriteAccountSpn); if (!PyArg_ParseTuple(args, "OlOO:DsWriteAccountSpn", &obhandle, &Operation, &obacct, &obspns)) return NULL; if (!PyWinObject_AsHANDLE(obhandle, &dshandle)) return NULL; if (!PyWinObject_AsWCHAR(obacct, &acct)) goto done; if (!PyWinObject_AsWCHARArray(obspns, &spns, &spn_cnt)) goto done; Py_BEGIN_ALLOW_THREADS err=(*pfnDsWriteAccountSpn)(dshandle, Operation, acct, spn_cnt, (LPCWSTR *)spns); Py_END_ALLOW_THREADS if (err!=STATUS_SUCCESS) PyWin_SetAPIError("DsWriteAccountSpn", err); else{ Py_INCREF(Py_None); ret=Py_None; } done: PyWinObject_FreeWCHAR(acct); PyWinObject_FreeWCHARArray(spns, spn_cnt); return ret; } PyObject *PyDsGetDcName(PyObject *self, PyObject *args, PyObject *kw) { static char *kw_items[]= { "computerName","domainName","domainGUID","siteName", "flags", NULL, }; CHECK_PFN(DsGetDcName); PyObject *obServer = Py_None, *obDomain = Py_None, *obSiteName = Py_None; PyObject *obGUID = Py_None; WCHAR *szServer = NULL, *szDomain = NULL, *szSiteName = NULL; GUID guidBuf, *pGUID = NULL; PyObject *ret = NULL; DOMAIN_CONTROLLER_INFO *pdci = NULL; DWORD flags = 0; DWORD err; if (!PyArg_ParseTupleAndKeywords(args, kw, "|OOOOi:DsGetDcName", kw_items, &obServer, &obDomain, &obGUID, &obSiteName, &flags)) return NULL; if (!PyWinObject_AsWCHAR(obServer, &szServer, TRUE)) goto done; if (!PyWinObject_AsWCHAR(obDomain, &szDomain, TRUE)) goto done; if (!PyWinObject_AsWCHAR(obSiteName, &szSiteName, TRUE)) goto done; if (obGUID != Py_None) { if (!PyWinObject_AsIID(obGUID, &guidBuf)) goto done; pGUID = &guidBuf; } Py_BEGIN_ALLOW_THREADS err = (*pfnDsGetDcName)(szServer, szDomain, pGUID, szSiteName, flags, &pdci); Py_END_ALLOW_THREADS if (err) { PyWin_SetAPIError("DsGetDcName", err); goto done; } ret = Py_BuildValue("{s:N,s:N,s:i,s:N,s:N,s:N,s:i,s:N,s:N}", "DomainControllerName", PyWinObject_FromTCHAR(pdci->DomainControllerName), "DomainControllerAddress", PyWinObject_FromTCHAR(pdci->DomainControllerAddress), "DomainControllerAddressType", pdci->DomainControllerAddressType, "DomainGuid", PyWinObject_FromIID(pdci->DomainGuid), "DomainName", PyWinObject_FromTCHAR(pdci->DomainName), "DnsForestName", PyWinObject_FromTCHAR(pdci->DnsForestName), "Flags", pdci->Flags, "DcSiteName", PyWinObject_FromTCHAR(pdci->DcSiteName), "ClientSiteName", PyWinObject_FromTCHAR(pdci->ClientSiteName)); // @rdesc The result is a dictionary with keys having the same name as the // Win32 DOMAIN_CONTROLLER_INFO struct. done: PyWinObject_FreeWCHAR(szServer); PyWinObject_FreeWCHAR(szDomain); PyWinObject_FreeWCHAR(szSiteName); NetApiBufferFree(pdci); return ret; } PyObject *PyDsCrackNames(PyObject *self, PyObject *args) { DWORD err; HANDLE dshandle; DS_NAME_FLAGS flags; DS_NAME_FORMAT formatOffered, formatDesired; PyObject *obNames; PyObject *ret=NULL, *obhandle; LPWSTR *names; DWORD cnames; PDS_NAME_RESULT dsresult = NULL; CHECK_PFN(DsCrackNames); CHECK_PFN(DsFreeNameResult); if (!PyArg_ParseTuple(args, "OlllO:DsCrackNames", &obhandle, &flags, &formatOffered, &formatDesired, &obNames)) return NULL; if (!PyWinObject_AsHANDLE(obhandle, &dshandle, TRUE)) return NULL; if (!PyWinObject_AsWCHARArray(obNames, &names, &cnames)) goto done; Py_BEGIN_ALLOW_THREADS err=(*pfnDsCrackNames)(dshandle, flags, formatOffered, formatDesired, cnames, names, &dsresult); Py_END_ALLOW_THREADS if (err!=STATUS_SUCCESS || !dsresult) PyWin_SetAPIError("DsWriteAccountSpn", err); else { ret = PyList_New(dsresult->cItems); if (!ret) goto done; for (DWORD i=0;i<dsresult->cItems;i++) { DS_NAME_RESULT_ITEM *pi = dsresult->rItems + i; PyList_SET_ITEM(ret, i, Py_BuildValue("iNN", pi->status, PyWinObject_FromWCHAR(pi->pDomain), PyWinObject_FromWCHAR(pi->pName))); } } done: PyWinObject_FreeWCHARArray(names, cnames); if (dsresult) (*pfnDsFreeNameResult)(dsresult); return ret; } Index: win32security_sspi.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security_sspi.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32security_sspi.cpp 9 Mar 2005 10:23:42 -0000 1.3 --- win32security_sspi.cpp 24 May 2005 13:55:30 -0000 1.4 *************** *** 299,305 **** --- 299,309 ---- #define OFF(e) offsetof(PySecBuffer, e) struct PyMemberDef PySecBuffer::members[] = { + // @prop int|BufferType| {"BufferType", T_ULONG, OFF(secbuffer.BufferType), 0, "Type of buffer, one of the SECBUFFER_* constants - can also be combined with SECBUFFER_READONLY"}, + // @prop string|Buffer| {"Buffer", T_OBJECT, OFF(obdummy), 0, "Encoded data buffer"}, + // @prop int|BufferSize| {"BufferSize", T_ULONG, OFF(secbuffer.cbBuffer), 0, "Current size of data in buffer"}, + // @prop int|MaxBufferSize| {"MaxBufferSize", T_ULONG, OFF(maxbufsize), READONLY, "Maximum size of data buffer"}, {NULL} *************** *** 626,630 **** --- 630,636 ---- return NULL; PCtxtHandle pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->MakeSignature)(pctxt, fqop, psecbufferdesc, seq_no); + Py_END_ALLOW_THREADS if (err<0){ PyWin_SetAPIError("MakeSignature",err); *************** *** 686,690 **** --- 692,698 ---- return NULL; PCtxtHandle pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->EncryptMessage)(pctxt, fqop, psecbufferdesc, seq_no); + Py_END_ALLOW_THREADS if (err<0){ PyWin_SetAPIError("EncryptMessage",err); *************** *** 718,722 **** --- 726,732 ---- return NULL; PCtxtHandle pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->DecryptMessage)(pctxt, psecbufferdesc, seq_no, &fqop); + Py_END_ALLOW_THREADS ((PySecBufferDesc *)obdesc)->modify_in_place(); if (err==SEC_E_OK) *************** *** 774,778 **** --- 784,790 ---- return NULL; pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->CompleteAuthToken)(pctxt, psecbufferdesc); + Py_END_ALLOW_THREADS if (err==SEC_E_OK){ Py_INCREF(Py_None); *************** *** 798,802 **** --- 810,816 ---- pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->QueryContextAttributesW)(pctxt, attr, &buf); + Py_END_ALLOW_THREADS if (err!=SEC_E_OK){ PyWin_SetAPIError("QueryContextAttributes",err); *************** *** 965,969 **** --- 979,985 ---- return NULL; pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->QuerySecurityContextToken)(pctxt, &htoken); + Py_END_ALLOW_THREADS if (err==SEC_E_OK) return PyWinObject_FromHANDLE(htoken); *************** *** 981,985 **** --- 997,1003 ---- return NULL; pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->ImpersonateSecurityContext)(pctxt); + Py_END_ALLOW_THREADS if (err==SEC_E_OK){ Py_INCREF(Py_None); *************** *** 999,1003 **** --- 1017,1023 ---- return NULL; pctxt=((PyCtxtHandle *)self)->GetCtxtHandle(); + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->RevertSecurityContext)(pctxt); + Py_END_ALLOW_THREADS if (err==SEC_E_OK){ Py_INCREF(Py_None); *************** *** 1190,1194 **** --- 1210,1216 ---- if (!PyArg_ParseTuple(args, "l:QueryCredentialsAttributes", &attr)) return NULL; + Py_BEGIN_ALLOW_THREADS err=(*psecurityfunctiontable->QueryCredentialsAttributesW)(pcredhandle, attr, &buf); + Py_END_ALLOW_THREADS if (err!=SEC_E_OK){ PyWin_SetAPIError("QueryCredentialsAttributes",err); *************** *** 1216,1458 **** } - // 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) - { - WCHAR *dc=NULL, *domain=NULL; - PyObject *obdc=Py_None, *obdomain=Py_None; - PyObject *ret=NULL; - DWORD err; - HANDLE dshandle; - - CHECK_PFN(DsBind); - if (!PyArg_ParseTuple(args, "|OO:DsBind", obdc, obdomain)) - return NULL; - if (PyWinObject_AsWCHAR(obdc, &dc, TRUE) && - PyWinObject_AsWCHAR(obdomain, &domain, TRUE)){ - err=(*pfnDsBind)(dc, domain, &dshandle); - if (err==NO_ERROR) - ret=new PyDS_HANDLE(dshandle); - else - PyWin_SetAPIError("DsBind",err); - } - PyWinObject_FreeWCHAR(dc); - PyWinObject_FreeWCHAR(domain); - return ret; - } - - extern PyObject *PyDsUnBind(PyObject *self, PyObject *args) - { - DWORD err; - HANDLE dshandle; - PyObject *obhandle; - - CHECK_PFN(DsUnBind); - if (!PyArg_ParseTuple(args, "O:DsUnBind", &obhandle)) - return NULL; - if (!PyWinObject_AsHANDLE(obhandle, &dshandle)) - return NULL; - err=(*pfnDsUnBind)(&dshandle); - if (err==NO_ERROR){ - Py_INCREF(Py_None); - return Py_None; - } - PyWin_SetAPIError("DsUnBind",err); - return NULL; - } - - void PyWinObject_FreeWCHARArray(LPWSTR *wchars, DWORD str_cnt) - { - if (wchars!=NULL){ - for (DWORD wchar_index=0; wchar_index<str_cnt; wchar_index++) - PyWinObject_FreeWCHAR(wchars[wchar_index]); - free(wchars); - } - } - - BOOL PyWinObject_AsWCHARArray(PyObject *str_seq, LPWSTR **wchars, DWORD *str_cnt) - { - BOOL ret=FALSE; - PyObject *str_tuple=NULL, *tuple_item; - DWORD bufsize, tuple_index; - *wchars=NULL; - *str_cnt=0; - if ((str_tuple=PySequence_Tuple(str_seq))==NULL) - return FALSE; - *str_cnt=PyTuple_Size(str_tuple); - bufsize=*str_cnt * sizeof(LPWSTR); - *wchars=(LPWSTR *)malloc(bufsize); - if (*wchars==NULL){ - PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); - goto done; - } - ZeroMemory(*wchars, bufsize); - for (tuple_index=0;tuple_index<*str_cnt;tuple_index++){ - tuple_item=PyTuple_GET_ITEM(str_tuple, tuple_index); - if (!PyWinObject_AsWCHAR(tuple_item, &((*wchars)[tuple_index]), FALSE)){ - PyWinObject_FreeWCHARArray(*wchars, *str_cnt); - *wchars=NULL; - *str_cnt=0; - goto done; - } - } - ret=TRUE; - done: - Py_XDECREF(str_tuple); - return ret; - } - - extern PyObject *PyDsGetSpn(PyObject *self, PyObject *args) - { - DWORD err, cSpns, bufsize, name_cnt; - DS_SPN_NAME_TYPE ServiceType; - WCHAR *ServiceClass=NULL, *ServiceName=NULL; - PyObject *obServiceClass, *obServiceName; - PyObject *ret=NULL, *tuple_item; - LPWSTR *Spns=NULL, *InstanceNames=NULL; - USHORT tuple_index, InstancePort=0, cInstanceNames=0, *InstancePorts=NULL; - long port_nbr; - PyObject *obInstanceNames=Py_None, *obInstancePorts=Py_None; - PyObject *obInstancePorts_tuple=NULL; - - CHECK_PFN(DsGetSpn); - CHECK_PFN(DsFreeSpnArray); - - if (!PyArg_ParseTuple(args,"lOO|HOO:DsGetSpn", &ServiceType, &obServiceClass, &obServiceName, - &InstancePort, &obInstanceNames, &obInstancePorts)) - return NULL; - if (!PyWinObject_AsWCHAR(obServiceClass, &ServiceClass, FALSE)) - goto done; - if (!PyWinObject_AsWCHAR(obServiceName, &ServiceName, TRUE)) - goto done; - if (obInstanceNames!=Py_None){ - if (!PyWinObject_AsWCHARArray(obInstanceNames, &InstanceNames, &name_cnt)) - goto done; - if (name_cnt>USHRT_MAX){ - PyErr_Format(PyExc_ValueError, "Count of InstanceNames cannot exceed %d", USHRT_MAX); - goto done; - } - cInstanceNames=(USHORT)name_cnt; - } - - if (obInstancePorts!=Py_None){ - if ((obInstancePorts_tuple=PySequence_Tuple(obInstancePorts))==NULL) - goto done; - if (PyTuple_Size(obInstancePorts_tuple)!=cInstanceNames){ - PyErr_SetString(PyExc_ValueError,"DsGetSpn: InstancePorts must be same size sequence as InstanceNames"); - goto done; - } - bufsize=cInstanceNames * sizeof(USHORT); - InstancePorts=(USHORT *)malloc(bufsize); - if (InstancePorts==NULL){ - PyErr_Format(PyExc_MemoryError, "DsGetSpn: Unable to allocate %d bytes", bufsize); - goto done; - } - for (tuple_index=0;tuple_index<cInstanceNames;tuple_index++){ - tuple_item=PyTuple_GET_ITEM(obInstancePorts_tuple,tuple_index); - // convert a python int to a USHORT - // ??? any API function to do this other than H format of PyArg_ParseTuple ??? - port_nbr=PyInt_AsLong(tuple_item); - if ((port_nbr==(unsigned long)-1 && PyErr_Occurred()) || (port_nbr<0)){ - PyErr_Clear(); - PyErr_Format(PyExc_TypeError,"InstancePorts must be a sequence of ints in the range 0-%d",USHRT_MAX); - goto done; - } - if (port_nbr > USHRT_MAX){ - PyErr_Format(PyExc_ValueError, "InstancePorts values cannot exceed %d", USHRT_MAX); - goto done; - } - InstancePorts[tuple_index]=(USHORT)port_nbr; - } - } - - err=(*pfnDsGetSpn)(ServiceType, ServiceClass, ServiceName, - InstancePort, cInstanceNames, (LPCWSTR *)InstanceNames, - InstancePorts, &cSpns, &Spns); - if (err!=STATUS_SUCCESS) - PyWin_SetAPIError("DsGetSpn",err); - else{ - ret=PyTuple_New(cSpns); - if (ret!=NULL){ - for (tuple_index=0;tuple_index<cSpns;tuple_index++){ - tuple_item=PyWinObject_FromWCHAR(Spns[tuple_index]); - if (tuple_item==NULL){ - Py_DECREF(ret); - ret=NULL; - break; - } - PyTuple_SET_ITEM(ret, tuple_index, tuple_item); - } - } - } - done: - if (Spns!=NULL) - (*pfnDsFreeSpnArray)(cSpns, Spns); - PyWinObject_FreeWCHARArray(InstanceNames, cInstanceNames); - - if (InstancePorts!=NULL) - free(InstancePorts); - if (obInstancePorts_tuple!=NULL) - Py_DECREF(obInstancePorts_tuple); - PyWinObject_FreeWCHAR(ServiceClass); - PyWinObject_FreeWCHAR(ServiceName); - return ret; - } - - extern PyObject *PyDsWriteAccountSpn(PyObject *self, PyObject *args) - { - DWORD err, spn_cnt; - HANDLE dshandle; - DS_SPN_WRITE_OP Operation; - LPWSTR acct, *spns=NULL; - PyObject *ret=NULL, *obhandle, *obacct, *obspns; - CHECK_PFN(DsWriteAccountSpn); - if (!PyArg_ParseTuple(args, "OlOO:DsWriteAccountSpn", &obhandle, &Operation, &obacct, &obspns)) - return NULL; - if (!PyWinObject_AsHANDLE(obhandle, &dshandle)) - return NULL; - if (!PyWinObject_AsWCHAR(obacct, &acct)) - goto done; - if (!PyWinObject_AsWCHARArray(obspns, &spns, &spn_cnt)) - goto done; - err=(*pfnDsWriteAccountSpn)(dshandle, Operation, acct, spn_cnt, (LPCWSTR *)spns); - if (err!=STATUS_SUCCESS) - PyWin_SetAPIError("DsWriteAccountSpn", err); - else{ - Py_INCREF(Py_None); - ret=Py_None; - } - done: - PyWinObject_FreeWCHAR(acct); - PyWinObject_FreeWCHARArray(spns, spn_cnt); - return ret; - } --- 1238,1239 ---- Index: win32security_sspi.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security_sspi.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32security_sspi.h 8 Mar 2005 13:13:03 -0000 1.2 --- win32security_sspi.h 24 May 2005 13:55:30 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- #include "ntdsapi.h" #include "subauth.h" + #include "Dsgetdc.h" // SecBuffer objects for SSPI functionality *************** *** 160,163 **** --- 161,165 ---- PyObject *PyDsBind(PyObject *self, PyObject *args); PyObject *PyDsUnBind(PyObject *self, PyObject *args); + PyObject *PyDsGetDcName(PyObject *self, PyObject *args, PyObject *kw); // function pointers that are initialized in win32security.i and used in win32security_sspi.cpp *************** *** 178,181 **** --- 180,192 ---- extern DsWriteAccountSpnfunc pfnDsWriteAccountSpn; + typedef DWORD (WINAPI *DsGetDcNamefunc)(LPCTSTR, LPCTSTR, GUID *, LPCTSTR, ULONG, PDOMAIN_CONTROLLER_INFO *); + extern DsGetDcNamefunc pfnDsGetDcName; + + typedef DWORD (WINAPI *DsCrackNamesfunc)(HANDLE, DS_NAME_FLAGS, DS_NAME_FORMAT, DS_NAME_FORMAT, DWORD, LPTSTR *, PDS_NAME_RESULT *); + extern DsCrackNamesfunc pfnDsCrackNames; + + typedef VOID (WINAPI *DsFreeNameResultfunc)(DS_NAME_RESULTW *); + extern DsFreeNameResultfunc pfnDsFreeNameResult; + #define CHECK_PFN(fname) if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** win32security.i 16 Apr 2005 01:29:35 -0000 1.24 --- win32security.i 24 May 2005 13:55:29 -0000 1.25 *************** *** 77,80 **** --- 77,83 ---- extern PSecurityFunctionTableW psecurityfunctiontable=NULL; + typedef BOOL (WINAPI *TranslateNamefunc)(LPCTSTR, EXTENDED_NAME_FORMAT, EXTENDED_NAME_FORMAT, LPTSTR, PULONG); + static TranslateNamefunc pfnTranslateName=NULL; + // function pointers used in win32security_sspi.cpp extern DsBindfunc pfnDsBind=NULL; *************** *** 83,86 **** --- 86,92 ---- extern DsWriteAccountSpnfunc pfnDsWriteAccountSpn=NULL; extern DsFreeSpnArrayfunc pfnDsFreeSpnArray=NULL; + extern DsGetDcNamefunc pfnDsGetDcName=NULL; + extern DsCrackNamesfunc pfnDsCrackNames=NULL; + extern DsFreeNameResultfunc pfnDsFreeNameResult=NULL; static HMODULE advapi32_dll=NULL; *************** *** 89,92 **** --- 95,99 ---- static HMODULE ntdll_dll =NULL; static HMODULE ntdsapi_dll =NULL; + static HMODULE netapi32_dll=NULL; HMODULE loadmodule(WCHAR *dllname) *************** *** 595,598 **** --- 602,606 ---- ntdll_dll =loadmodule(_T("ntdll.dll")); ntdsapi_dll =loadmodule(_T("ntdsapi.dll")); + netapi32_dll =loadmodule(_T("netapi32.dll")); pfnCheckTokenMembership=(CheckTokenMembershipfunc)loadapifunc("CheckTokenMembership", advapi32_dll); *************** *** 634,637 **** --- 642,647 ---- if (pfnInitSecurityInterface!=NULL) psecurityfunctiontable=(*pfnInitSecurityInterface)(); + + pfnTranslateName=(TranslateNamefunc)loadapifunc("TranslateNameW",secur32_dll); pfnDsBind=(DsBindfunc)loadapifunc("DsBindW", ntdsapi_dll); *************** *** 640,643 **** --- 650,656 ---- pfnDsWriteAccountSpn=(DsWriteAccountSpnfunc)loadapifunc("DsWriteAccountSpnW", ntdsapi_dll); pfnDsFreeSpnArray=(DsFreeSpnArrayfunc)loadapifunc("DsFreeSpnArrayW", ntdsapi_dll); + pfnDsCrackNames=(DsCrackNamesfunc)loadapifunc("DsCrackNamesW", ntdsapi_dll); + pfnDsFreeNameResult=(DsFreeNameResultfunc)loadapifunc("DsFreeNameResultW", ntdsapi_dll); + pfnDsGetDcName=(DsGetDcNamefunc)loadapifunc("DsGetDcNameW", netapi32_dll); PyDict_SetItemString(d, "SecBufferType", (PyObject *)&PySecBufferType); *************** *** 645,648 **** --- 658,668 ---- PyDict_SetItemString(d, "CtxtHandleType", (PyObject *)&PyCtxtHandleType); PyDict_SetItemString(d, "CredHandleType", (PyObject *)&PyCredHandleType); + + // Patch up any kwarg functions - SWIG doesn't like them. + for (PyMethodDef *pmd = win32securityMethods;pmd->ml_name;pmd++) + if (strcmp(pmd->ml_name, "DsGetDcName")==0) { + pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; + break; // only 1 name at the moment. + } %} *************** *** 673,676 **** --- 693,717 ---- // @pyparm <o PyHANDLE>|hDS||A handle to a directory service as returned by <om win32security.DsBind> + %{ + // work around issues with SWIG and kwargs. + #define PYDSGETDCNAME (PyCFunction)PyDsGetDcName + %} + %native (DsGetDcName) PYDSGETDCNAME; + // @pyswig dict|DsGetDcName|Returns the name of a domain controller (DC) in a specified domain. + // You can supply DC selection criteria to this function to indicate preference for a DC with particular characteristics. + // @comm This function supports keyword arguments. + // @pyparm <o PyUnicode>|computerName|None| + // @pyparm <o PyUnicode>|domainName|None| + // @pyparm <o PyIID>|domainGUID|None| + // @pyparm <o PyUnicode>|siteName|None| + // @pyparm int|flags|0| + + %native (DsCrackNames) extern PyObject *PyDsCrackNames(PyObject *self, PyObject *args); + // @pyswig [ (status, domain, name) ]|DsCrackNames|Converts an array of directory service object names from one format to another. + // @pyswig int|flags|| + // @pyparm int|formatOffered|| + // @pyparm int|formatDesired|| + // @pyparm [name, ...]|names|| + // @pyswig PyACL|ACL|Creates a new <o PyACL> object. // @pyparm int|bufSize|64|The size of the buffer for the ACL. *************** *** 3353,3356 **** --- 3394,3437 ---- %} + // @pyswig |TranslateName|Converts a directory service object name from one format to another. + %native(TranslateName) PyTranslateName; + %{ + static PyObject *PyTranslateName(PyObject *self, PyObject *args) + { + PyObject *obAcctName; + int format, desiredFormat; + ULONG numChars = 1024; + CHECK_PFN(TranslateName); + WCHAR *szAcctName = NULL; + WCHAR *buf = NULL; + BOOL ok; + if (!PyArg_ParseTuple(args, "Oii|l", + &obAcctName, // @pyparm <o PyUnicode>|accountName||object name + &format, // @pyparm int|accountNameFormat||A value from the EXTENDED_NAME_FORMAT enumeration type indicating the format of the accountName name. + &desiredFormat, // @pyparm int|accountNameFormat||A value from the EXTENDED_NAME_FORMAT enumeration type indicating the format of the desired name. + &numChars)) // @pyparm int|numChars|1024|Number of Unicode characters to allocate for the return buffer. + return NULL; + if (!PyWinObject_AsWCHAR(obAcctName, &szAcctName, FALSE)) + return NULL; + buf = (WCHAR *)malloc(sizeof(WCHAR) * numChars); + if (!buf) { + PyWinObject_FreeWCHAR(szAcctName); + return PyErr_NoMemory(); + } + Py_BEGIN_ALLOW_THREADS + ok = (*pfnTranslateName)(szAcctName, (EXTENDED_NAME_FORMAT)format, + (EXTENDED_NAME_FORMAT)desiredFormat, buf, &numChars); + Py_END_ALLOW_THREADS + PyObject *ret = NULL; + if (ok) { + ret = PyWinObject_FromWCHAR(buf, numChars-1); + } else + PyWin_SetAPIError("TranslateName"); + PyWinObject_FreeWCHAR(szAcctName); + free(buf); + return ret; + } + %} + #define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token. #define TOKEN_ADJUST_GROUPS TOKEN_ADJUST_GROUPS // Required to change the groups specified in an access token. |
From: Mark H. <mha...@us...> - 2005-05-24 13:55:39
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17051/win32/test Modified Files: test_security.py Log Message: * setup.py now allows sources to be specified; win32security and win32net now do so, making their .dsp files redundant. * Existing win32security Ds* (DirectoryService) functions (not to be confused with the COM related win32com.adsi module!) split into new win32security_ds.cpp module. * New win32security functions TranslateName, DsGetDcName and DsCrackNames * Release the GIL when calling SSPI and DS functions. * New Ds related constants in ntsecuritycon. * New tests for these functions. Index: test_security.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_security.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_security.py 23 Oct 2003 05:17:04 -0000 1.2 --- test_security.py 24 May 2005 13:55:30 -0000 1.3 *************** *** 2,6 **** import unittest ! import win32api, win32con, win32security class SecurityTests(unittest.TestCase): --- 2,6 ---- import unittest ! import win32api, win32con, win32security, ntsecuritycon class SecurityTests(unittest.TestCase): *************** *** 31,34 **** --- 31,77 ---- sd4.SetSecurityDescriptorSacl(1,sacl,0) + class TestDS(unittest.TestCase): + def testDsGetDcName(self): + # Not sure what we can actually test here! At least calling it + # does something :) + win32security.DsGetDcName() + + def testDsCrackNames(self): + h = win32security.DsBind() + fmt_offered = ntsecuritycon.DS_FQDN_1779_NAME + name = win32api.GetUserNameEx(fmt_offered) + result = win32security.DsCrackNames(h, 0, fmt_offered, fmt_offered, (name,)) + self.failUnlessEqual(name, result[0][2]) + + def testDsCrackNamesSyntax(self): + # Do a syntax check only - that allows us to avoid binding. + # But must use DS_CANONICAL_NAME (or _EX) + expected = win32api.GetUserNameEx(win32api.NameCanonical) + fmt_offered = ntsecuritycon.DS_FQDN_1779_NAME + name = win32api.GetUserNameEx(fmt_offered) + result = win32security.DsCrackNames(None, ntsecuritycon.DS_NAME_FLAG_SYNTACTICAL_ONLY, + fmt_offered, ntsecuritycon.DS_CANONICAL_NAME, + (name,)) + self.failUnlessEqual(expected, result[0][2]) + + class TestTranslate(unittest.TestCase): + def _testTranslate(self, fmt_from, fmt_to): + name = win32api.GetUserNameEx(fmt_from) + expected = win32api.GetUserNameEx(fmt_to) + got = win32security.TranslateName(name, fmt_from, fmt_to) + self.failUnlessEqual(got, expected) + + def testTranslate1(self): + self._testTranslate(win32api.NameFullyQualifiedDN, win32api.NameSamCompatible) + + def testTranslate2(self): + self._testTranslate(win32api.NameSamCompatible, win32api.NameFullyQualifiedDN) + + def testTranslate3(self): + self._testTranslate(win32api.NameFullyQualifiedDN, win32api.NameUniqueId) + + def testTranslate4(self): + self._testTranslate(win32api.NameUniqueId, win32api.NameFullyQualifiedDN) + if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2005-05-24 13:55:38
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17051/win32/Lib Modified Files: ntsecuritycon.py Log Message: * setup.py now allows sources to be specified; win32security and win32net now do so, making their .dsp files redundant. * Existing win32security Ds* (DirectoryService) functions (not to be confused with the COM related win32com.adsi module!) split into new win32security_ds.cpp module. * New win32security functions TranslateName, DsGetDcName and DsCrackNames * Release the GIL when calling SSPI and DS functions. * New Ds related constants in ntsecuritycon. * New tests for these functions. Index: ntsecuritycon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/ntsecuritycon.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ntsecuritycon.py 2 Jul 2003 03:39:12 -0000 1.3 --- ntsecuritycon.py 24 May 2005 13:55:28 -0000 1.4 *************** *** 248,249 **** --- 248,566 ---- TokenStatistics = 10 + # DirectoryService related constants. + # Generated by h2py from NtDsAPI.h + DS_BEHAVIOR_WIN2000 = 0 + DS_BEHAVIOR_WIN2003_WITH_MIXED_DOMAINS = 1 + DS_BEHAVIOR_WIN2003 = 2 + DS_SYNCED_EVENT_NAME = "NTDSInitialSyncsCompleted" + ACTRL_DS_OPEN = 0x00000000 + ACTRL_DS_CREATE_CHILD = 0x00000001 + ACTRL_DS_DELETE_CHILD = 0x00000002 + ACTRL_DS_LIST = 0x00000004 + ACTRL_DS_SELF = 0x00000008 + ACTRL_DS_READ_PROP = 0x00000010 + ACTRL_DS_WRITE_PROP = 0x00000020 + ACTRL_DS_DELETE_TREE = 0x00000040 + ACTRL_DS_LIST_OBJECT = 0x00000080 + ACTRL_DS_CONTROL_ACCESS = 0x00000100 + NTDSAPI_BIND_ALLOW_DELEGATION = (0x00000001) + DS_REPSYNC_ASYNCHRONOUS_OPERATION = 0x00000001 + DS_REPSYNC_WRITEABLE = 0x00000002 + DS_REPSYNC_PERIODIC = 0x00000004 + DS_REPSYNC_INTERSITE_MESSAGING = 0x00000008 + DS_REPSYNC_ALL_SOURCES = 0x00000010 + DS_REPSYNC_FULL = 0x00000020 + DS_REPSYNC_URGENT = 0x00000040 + DS_REPSYNC_NO_DISCARD = 0x00000080 + DS_REPSYNC_FORCE = 0x00000100 + DS_REPSYNC_ADD_REFERENCE = 0x00000200 + DS_REPSYNC_NEVER_COMPLETED = 0x00000400 + DS_REPSYNC_TWO_WAY = 0x00000800 + DS_REPSYNC_NEVER_NOTIFY = 0x00001000 + DS_REPSYNC_INITIAL = 0x00002000 + DS_REPSYNC_USE_COMPRESSION = 0x00004000 + DS_REPSYNC_ABANDONED = 0x00008000 + DS_REPSYNC_INITIAL_IN_PROGRESS = 0x00010000 + DS_REPSYNC_PARTIAL_ATTRIBUTE_SET = 0x00020000 + DS_REPSYNC_REQUEUE = 0x00040000 + DS_REPSYNC_NOTIFICATION = 0x00080000 + DS_REPSYNC_ASYNCHRONOUS_REPLICA = 0x00100000 + DS_REPSYNC_CRITICAL = 0x00200000 + DS_REPSYNC_FULL_IN_PROGRESS = 0x00400000 + DS_REPSYNC_PREEMPTED = 0x00800000 + DS_REPADD_ASYNCHRONOUS_OPERATION = 0x00000001 + DS_REPADD_WRITEABLE = 0x00000002 + DS_REPADD_INITIAL = 0x00000004 + DS_REPADD_PERIODIC = 0x00000008 + DS_REPADD_INTERSITE_MESSAGING = 0x00000010 + DS_REPADD_ASYNCHRONOUS_REPLICA = 0x00000020 + DS_REPADD_DISABLE_NOTIFICATION = 0x00000040 + DS_REPADD_DISABLE_PERIODIC = 0x00000080 + DS_REPADD_USE_COMPRESSION = 0x00000100 + DS_REPADD_NEVER_NOTIFY = 0x00000200 + DS_REPADD_TWO_WAY = 0x00000400 + DS_REPADD_CRITICAL = 0x00000800 + DS_REPDEL_ASYNCHRONOUS_OPERATION = 0x00000001 + DS_REPDEL_WRITEABLE = 0x00000002 + DS_REPDEL_INTERSITE_MESSAGING = 0x00000004 + DS_REPDEL_IGNORE_ERRORS = 0x00000008 + DS_REPDEL_LOCAL_ONLY = 0x00000010 + DS_REPDEL_NO_SOURCE = 0x00000020 + DS_REPDEL_REF_OK = 0x00000040 + DS_REPMOD_ASYNCHRONOUS_OPERATION = 0x00000001 + DS_REPMOD_WRITEABLE = 0x00000002 + DS_REPMOD_UPDATE_FLAGS = 0x00000001 + DS_REPMOD_UPDATE_ADDRESS = 0x00000002 + DS_REPMOD_UPDATE_SCHEDULE = 0x00000004 + DS_REPMOD_UPDATE_RESULT = 0x00000008 + DS_REPMOD_UPDATE_TRANSPORT = 0x00000010 + DS_REPUPD_ASYNCHRONOUS_OPERATION = 0x00000001 + DS_REPUPD_WRITEABLE = 0x00000002 + DS_REPUPD_ADD_REFERENCE = 0x00000004 + DS_REPUPD_DELETE_REFERENCE = 0x00000008 + DS_INSTANCETYPE_IS_NC_HEAD = 0x00000001 + DS_INSTANCETYPE_NC_IS_WRITEABLE = 0x00000004 + DS_INSTANCETYPE_NC_COMING = 0x00000010 + DS_INSTANCETYPE_NC_GOING = 0x00000020 + NTDSDSA_OPT_IS_GC = ( 1 << 0 ) + NTDSDSA_OPT_DISABLE_INBOUND_REPL = ( 1 << 1 ) + NTDSDSA_OPT_DISABLE_OUTBOUND_REPL = ( 1 << 2 ) + NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE = ( 1 << 3 ) + NTDSCONN_OPT_IS_GENERATED = ( 1 << 0 ) + NTDSCONN_OPT_TWOWAY_SYNC = ( 1 << 1 ) + NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT = (1 << 2 ) + NTDSCONN_OPT_USE_NOTIFY = (1 << 3) + NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION = (1 << 4) + NTDSCONN_OPT_USER_OWNED_SCHEDULE = (1 << 5) + NTDSCONN_KCC_NO_REASON = ( 0 ) + NTDSCONN_KCC_GC_TOPOLOGY = ( 1 << 0 ) + NTDSCONN_KCC_RING_TOPOLOGY = ( 1 << 1 ) + NTDSCONN_KCC_MINIMIZE_HOPS_TOPOLOGY = ( 1 << 2 ) + NTDSCONN_KCC_STALE_SERVERS_TOPOLOGY = ( 1 << 3 ) + NTDSCONN_KCC_OSCILLATING_CONNECTION_TOPOLOGY = ( 1 << 4 ) + NTDSCONN_KCC_INTERSITE_GC_TOPOLOGY = (1 << 5) + NTDSCONN_KCC_INTERSITE_TOPOLOGY = (1 << 6) + NTDSCONN_KCC_SERVER_FAILOVER_TOPOLOGY = (1 << 7) + NTDSCONN_KCC_SITE_FAILOVER_TOPOLOGY = (1 << 8) + NTDSCONN_KCC_REDUNDANT_SERVER_TOPOLOGY = (1 << 9) + FRSCONN_PRIORITY_MASK = 0x70000000 + FRSCONN_MAX_PRIORITY = 0x8 + NTDSCONN_OPT_IGNORE_SCHEDULE_MASK = (-2147483648) + + NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED = ( 1 << 0 ) + NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED = ( 1 << 1 ) + NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED = ( 1 << 2 ) + NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED = ( 1 << 3 ) + NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED = ( 1 << 4 ) + NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED = ( 1 << 5 ) + NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR = ( 1 << 6 ) + NTDSSETTINGS_OPT_FORCE_KCC_W2K_ELECTION = ( 1 << 7 ) + NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED = ( 1 << 8 ) + NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED = ( 1 << 9 ) + NTDSSETTINGS_OPT_IS_REDUNDANT_SERVER_TOPOLOGY_ENABLED = ( 1 << 10 ) + NTDSSETTINGS_DEFAULT_SERVER_REDUNDANCY = 2 + NTDSTRANSPORT_OPT_IGNORE_SCHEDULES = ( 1 << 0 ) + NTDSTRANSPORT_OPT_BRIDGES_REQUIRED = (1 << 1 ) + NTDSSITECONN_OPT_USE_NOTIFY = ( 1 << 0 ) + NTDSSITECONN_OPT_TWOWAY_SYNC = ( 1 << 1 ) + NTDSSITECONN_OPT_DISABLE_COMPRESSION = ( 1 << 2 ) + NTDSSITELINK_OPT_USE_NOTIFY = ( 1 << 0 ) + NTDSSITELINK_OPT_TWOWAY_SYNC = ( 1 << 1 ) + NTDSSITELINK_OPT_DISABLE_COMPRESSION = ( 1 << 2 ) + GUID_USERS_CONTAINER_A = "a9d1ca15768811d1aded00c04fd8d5cd" + GUID_COMPUTRS_CONTAINER_A = "aa312825768811d1aded00c04fd8d5cd" + GUID_SYSTEMS_CONTAINER_A = "ab1d30f3768811d1aded00c04fd8d5cd" + GUID_DOMAIN_CONTROLLERS_CONTAINER_A = "a361b2ffffd211d1aa4b00c04fd7d83a" + GUID_INFRASTRUCTURE_CONTAINER_A = "2fbac1870ade11d297c400c04fd8d5cd" + GUID_DELETED_OBJECTS_CONTAINER_A = "18e2ea80684f11d2b9aa00c04f79f805" + GUID_LOSTANDFOUND_CONTAINER_A = "ab8153b7768811d1aded00c04fd8d5cd" + GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_A = "22b70c67d56e4efb91e9300fca3dc1aa" + GUID_PROGRAM_DATA_CONTAINER_A = "09460c08ae1e4a4ea0f64aee7daa1e5a" + GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_A = "f4be92a4c777485e878e9421d53087db" + GUID_NTDS_QUOTAS_CONTAINER_A = "6227f0af1fc2410d8e3bb10615bb5b0f" + GUID_USERS_CONTAINER_BYTE = "\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd" + GUID_COMPUTRS_CONTAINER_BYTE = "\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd" + GUID_SYSTEMS_CONTAINER_BYTE = "\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd" + GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE = "\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a" + GUID_INFRASTRUCTURE_CONTAINER_BYTE = "\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd" + GUID_DELETED_OBJECTS_CONTAINER_BYTE = "\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05" + GUID_LOSTANDFOUND_CONTAINER_BYTE = "\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd" + GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_BYTE = "\x22\xb7\x0c\x67\xd5\x6e\x4e\xfb\x91\xe9\x30\x0f\xca\x3d\xc1\xaa" + GUID_PROGRAM_DATA_CONTAINER_BYTE = "\x09\x46\x0c\x08\xae\x1e\x4a\x4e\xa0\xf6\x4a\xee\x7d\xaa\x1e\x5a" + GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_BYTE = "\xf4\xbe\x92\xa4\xc7\x77\x48\x5e\x87\x8e\x94\x21\xd5\x30\x87\xdb" + GUID_NTDS_QUOTAS_CONTAINER_BYTE = "\x62\x27\xf0\xaf\x1f\xc2\x41\x0d\x8e\x3b\xb1\x06\x15\xbb\x5b\x0f" + DS_REPSYNCALL_NO_OPTIONS = 0x00000000 + DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE = 0x00000001 + DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY = 0x00000002 + DS_REPSYNCALL_ID_SERVERS_BY_DN = 0x00000004 + DS_REPSYNCALL_DO_NOT_SYNC = 0x00000008 + DS_REPSYNCALL_SKIP_INITIAL_CHECK = 0x00000010 + DS_REPSYNCALL_PUSH_CHANGES_OUTWARD = 0x00000020 + DS_REPSYNCALL_CROSS_SITE_BOUNDARIES = 0x00000040 + DS_LIST_DSA_OBJECT_FOR_SERVER = 0 + DS_LIST_DNS_HOST_NAME_FOR_SERVER = 1 + DS_LIST_ACCOUNT_OBJECT_FOR_SERVER = 2 + DS_ROLE_SCHEMA_OWNER = 0 + DS_ROLE_DOMAIN_OWNER = 1 + DS_ROLE_PDC_OWNER = 2 + DS_ROLE_RID_OWNER = 3 + DS_ROLE_INFRASTRUCTURE_OWNER = 4 + DS_SCHEMA_GUID_NOT_FOUND = 0 + DS_SCHEMA_GUID_ATTR = 1 + DS_SCHEMA_GUID_ATTR_SET = 2 + DS_SCHEMA_GUID_CLASS = 3 + DS_SCHEMA_GUID_CONTROL_RIGHT = 4 + DS_KCC_FLAG_ASYNC_OP = (1 << 0) + DS_KCC_FLAG_DAMPED = (1 << 1) + DS_EXIST_ADVISORY_MODE = (0x1) + DS_REPL_INFO_FLAG_IMPROVE_LINKED_ATTRS = (0x00000001) + DS_REPL_NBR_WRITEABLE = (0x00000010) + DS_REPL_NBR_SYNC_ON_STARTUP = (0x00000020) + DS_REPL_NBR_DO_SCHEDULED_SYNCS = (0x00000040) + DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT = (0x00000080) + DS_REPL_NBR_TWO_WAY_SYNC = (0x00000200) + DS_REPL_NBR_RETURN_OBJECT_PARENTS = (0x00000800) + DS_REPL_NBR_FULL_SYNC_IN_PROGRESS = (0x00010000) + DS_REPL_NBR_FULL_SYNC_NEXT_PACKET = (0x00020000) + DS_REPL_NBR_NEVER_SYNCED = (0x00200000) + DS_REPL_NBR_PREEMPTED = (0x01000000) + DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS = (0x04000000) + DS_REPL_NBR_DISABLE_SCHEDULED_SYNC = (0x08000000) + DS_REPL_NBR_COMPRESS_CHANGES = (0x10000000) + DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS = (0x20000000) + DS_REPL_NBR_PARTIAL_ATTRIBUTE_SET = (0x40000000) + DS_REPL_NBR_MODIFIABLE_MASK = \ + ( \ + DS_REPL_NBR_SYNC_ON_STARTUP | \ + DS_REPL_NBR_DO_SCHEDULED_SYNCS | \ + DS_REPL_NBR_TWO_WAY_SYNC | \ + DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS | \ + DS_REPL_NBR_DISABLE_SCHEDULED_SYNC | \ + DS_REPL_NBR_COMPRESS_CHANGES | \ + DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS \ + ) + + # from enum DS_NAME_FORMAT + DS_UNKNOWN_NAME = 0 + DS_FQDN_1779_NAME = 1 + DS_NT4_ACCOUNT_NAME = 2 + DS_DISPLAY_NAME = 3 + DS_UNIQUE_ID_NAME = 6 + DS_CANONICAL_NAME = 7 + DS_USER_PRINCIPAL_NAME = 8 + DS_CANONICAL_NAME_EX = 9 + DS_SERVICE_PRINCIPAL_NAME = 10 + DS_SID_OR_SID_HISTORY_NAME = 11 + DS_DNS_DOMAIN_NAME = 12 + + DS_DOMAIN_SIMPLE_NAME = DS_USER_PRINCIPAL_NAME + DS_ENTERPRISE_SIMPLE_NAME = DS_USER_PRINCIPAL_NAME + + # from enum DS_NAME_FLAGS + DS_NAME_NO_FLAGS = 0x0 + DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1 + DS_NAME_FLAG_EVAL_AT_DC = 0x2 + DS_NAME_FLAG_GCVERIFY = 0x4 + DS_NAME_FLAG_TRUST_REFERRAL = 0x8 + + # from enum DS_NAME_ERROR + DS_NAME_NO_ERROR = 0 + DS_NAME_ERROR_RESOLVING = 1 + DS_NAME_ERROR_NOT_FOUND = 2 + DS_NAME_ERROR_NOT_UNIQUE = 3 + DS_NAME_ERROR_NO_MAPPING = 4 + DS_NAME_ERROR_DOMAIN_ONLY = 5 + DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6 + DS_NAME_ERROR_TRUST_REFERRAL = 7 + + + # from enum DS_SPN_NAME_TYPE + DS_SPN_DNS_HOST = 0 + DS_SPN_DN_HOST = 1 + DS_SPN_NB_HOST = 2 + DS_SPN_DOMAIN = 3 + DS_SPN_NB_DOMAIN = 4 + DS_SPN_SERVICE = 5 + + # from enum DS_SPN_WRITE_OP + DS_SPN_ADD_SPN_OP = 0 + DS_SPN_REPLACE_SPN_OP = 1 + DS_SPN_DELETE_SPN_OP = 2 + + # Generated by h2py from DsGetDC.h + DS_FORCE_REDISCOVERY = 0x00000001 + DS_DIRECTORY_SERVICE_REQUIRED = 0x00000010 + DS_DIRECTORY_SERVICE_PREFERRED = 0x00000020 + DS_GC_SERVER_REQUIRED = 0x00000040 + DS_PDC_REQUIRED = 0x00000080 + DS_BACKGROUND_ONLY = 0x00000100 + DS_IP_REQUIRED = 0x00000200 + DS_KDC_REQUIRED = 0x00000400 + DS_TIMESERV_REQUIRED = 0x00000800 + DS_WRITABLE_REQUIRED = 0x00001000 + DS_GOOD_TIMESERV_PREFERRED = 0x00002000 + DS_AVOID_SELF = 0x00004000 + DS_ONLY_LDAP_NEEDED = 0x00008000 + DS_IS_FLAT_NAME = 0x00010000 + DS_IS_DNS_NAME = 0x00020000 + DS_RETURN_DNS_NAME = 0x40000000 + DS_RETURN_FLAT_NAME = (-2147483648) + DSGETDC_VALID_FLAGS = ( \ + DS_FORCE_REDISCOVERY | \ + DS_DIRECTORY_SERVICE_REQUIRED | \ + DS_DIRECTORY_SERVICE_PREFERRED | \ + DS_GC_SERVER_REQUIRED | \ + DS_PDC_REQUIRED | \ + DS_BACKGROUND_ONLY | \ + DS_IP_REQUIRED | \ + DS_KDC_REQUIRED | \ + DS_TIMESERV_REQUIRED | \ + DS_WRITABLE_REQUIRED | \ + DS_GOOD_TIMESERV_PREFERRED | \ + DS_AVOID_SELF | \ + DS_ONLY_LDAP_NEEDED | \ + DS_IS_FLAT_NAME | \ + DS_IS_DNS_NAME | \ + DS_RETURN_FLAT_NAME | \ + DS_RETURN_DNS_NAME ) + DS_INET_ADDRESS = 1 + DS_NETBIOS_ADDRESS = 2 + DS_PDC_FLAG = 0x00000001 + DS_GC_FLAG = 0x00000004 + DS_LDAP_FLAG = 0x00000008 + DS_DS_FLAG = 0x00000010 + DS_KDC_FLAG = 0x00000020 + DS_TIMESERV_FLAG = 0x00000040 + DS_CLOSEST_FLAG = 0x00000080 + DS_WRITABLE_FLAG = 0x00000100 + DS_GOOD_TIMESERV_FLAG = 0x00000200 + DS_NDNC_FLAG = 0x00000400 + DS_PING_FLAGS = 0x0000FFFF + DS_DNS_CONTROLLER_FLAG = 0x20000000 + DS_DNS_DOMAIN_FLAG = 0x40000000 + DS_DNS_FOREST_FLAG = (-2147483648) + DS_DOMAIN_IN_FOREST = 0x0001 + DS_DOMAIN_DIRECT_OUTBOUND = 0x0002 + DS_DOMAIN_TREE_ROOT = 0x0004 + DS_DOMAIN_PRIMARY = 0x0008 + DS_DOMAIN_NATIVE_MODE = 0x0010 + DS_DOMAIN_DIRECT_INBOUND = 0x0020 + DS_DOMAIN_VALID_FLAGS = ( \ + DS_DOMAIN_IN_FOREST | \ + DS_DOMAIN_DIRECT_OUTBOUND | \ + DS_DOMAIN_TREE_ROOT | \ + DS_DOMAIN_PRIMARY | \ + DS_DOMAIN_NATIVE_MODE | \ + DS_DOMAIN_DIRECT_INBOUND ) + DS_GFTI_UPDATE_TDO = 0x1 + DS_GFTI_VALID_FLAGS = 0x1 + DS_ONLY_DO_SITE_NAME = 0x01 + DS_NOTIFY_AFTER_SITE_RECORDS = 0x02 + DS_OPEN_VALID_OPTION_FLAGS = ( DS_ONLY_DO_SITE_NAME | DS_NOTIFY_AFTER_SITE_RECORDS ) + DS_OPEN_VALID_FLAGS = ( \ + DS_FORCE_REDISCOVERY | \ + DS_ONLY_LDAP_NEEDED | \ + DS_KDC_REQUIRED | \ + DS_PDC_REQUIRED | \ + DS_GC_SERVER_REQUIRED | \ + DS_WRITABLE_REQUIRED ) |
From: Mark H. <mha...@us...> - 2005-05-24 13:55:37
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17051 Modified Files: setup.py Log Message: * setup.py now allows sources to be specified; win32security and win32net now do so, making their .dsp files redundant. * Existing win32security Ds* (DirectoryService) functions (not to be confused with the COM related win32com.adsi module!) split into new win32security_ds.cpp module. * New win32security functions TranslateName, DsGetDcName and DsCrackNames * Release the GIL when calling SSPI and DS functions. * New Ds related constants in ntsecuritycon. * New tests for these functions. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** setup.py 12 Apr 2005 07:26:40 -0000 1.7 --- setup.py 24 May 2005 13:55:28 -0000 1.8 *************** *** 1,3 **** ! build_number=204 # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) --- 1,3 ---- ! build_number=204.1 # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) *************** *** 197,201 **** class WinExt_win32(WinExt): def __init__ (self, name, **kw): ! if not kw.has_key("dsp_file"): kw["dsp_file"] = "win32/" + name + ".dsp" WinExt.__init__(self, name, **kw) --- 197,201 ---- class WinExt_win32(WinExt): def __init__ (self, name, **kw): ! if not kw.has_key("dsp_file") and not kw.get("sources"): kw["dsp_file"] = "win32/" + name + ".dsp" WinExt.__init__(self, name, **kw) *************** *** 825,829 **** ("win32help", "htmlhelp user32 advapi32", False, 0x0500), ("win32lz", "lz32", False), ! ("win32net", "netapi32", True), ("win32pdh", "", False), ("win32pipe", "", False), --- 825,834 ---- ("win32help", "htmlhelp user32 advapi32", False, 0x0500), ("win32lz", "lz32", False), ! ("win32net", "netapi32", True, None, """ ! win32/src/win32net/win32netfile.cpp win32/src/win32net/win32netgroup.cpp ! win32/src/win32net/win32netmisc.cpp win32/src/win32net/win32netmodule.cpp ! win32/src/win32net/win32netsession.cpp win32/src/win32net/win32netuse.cpp ! win32/src/win32net/win32netuser.cpp ! """), ("win32pdh", "", False), ("win32pipe", "", False), *************** *** 831,835 **** ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), ! ("win32security", "advapi32 user32", True), ("win32service", "advapi32 oleaut32 user32", True, 0x0500), ("win32trace", "advapi32", False), --- 836,843 ---- ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), ! ("win32security", "advapi32 user32 netapi32", True, None, """ ! win32/src/win32security.i win32/src/win32securitymodule.cpp ! win32/src/win32security_sspi.cpp win32/src/win32security_ds.cpp ! """), ("win32service", "advapi32 oleaut32 user32", True, 0x0500), ("win32trace", "advapi32", False), *************** *** 839,846 **** name, lib_names, is_unicode = info[:3] if len(info)>3: windows_h_ver = info[3] ! else: ! windows_h_ver = None extra_compile_args = [] if is_unicode: --- 847,855 ---- name, lib_names, is_unicode = info[:3] + windows_h_ver = sources = None if len(info)>3: windows_h_ver = info[3] ! if len(info)>4: ! sources = info[4].split() extra_compile_args = [] if is_unicode: *************** *** 849,853 **** libraries=lib_names, extra_compile_args = extra_compile_args, ! windows_h_version = windows_h_ver) win32_extensions.append(ext) --- 858,863 ---- libraries=lib_names, extra_compile_args = extra_compile_args, ! windows_h_version = windows_h_ver, ! sources = sources) win32_extensions.append(ext) |
From: Mark H. <mha...@us...> - 2005-05-24 13:27:02
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/security/sspi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10712 Modified Files: validate_password.py Log Message: Don't insist on a password, just to see what the API does when a domain-admin doesn't supply one. Index: validate_password.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/sspi/validate_password.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** validate_password.py 7 Mar 2005 11:16:19 -0000 1.2 --- validate_password.py 24 May 2005 13:26:48 -0000 1.3 *************** *** 20,32 **** if __name__=='__main__': ! if len(sys.argv) not in [3,4]: ! print "Usage: %s username password [domain]" % (__file__,) sys.exit(1) ! domain = "" # optional! ! if len(sys.argv)==4: domain = sys.argv[3] try: ! validate(sys.argv[1], sys.argv[2], domain) print "Validated OK" except win32security.error, details: --- 20,36 ---- if __name__=='__main__': ! if len(sys.argv) not in [2,3,4]: ! print "Usage: %s username [password [domain]]" % (__file__,) sys.exit(1) ! # password and domain are optional! ! password = None ! if len(sys.argv)>=3: ! password = sys.argv[2] ! domain = "" ! if len(sys.argv)>=4: domain = sys.argv[3] try: ! validate(sys.argv[1], password, domain) print "Validated OK" except win32security.error, details: |
From: Roger U. <ru...@us...> - 2005-05-23 14:28:08
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28781/win32/src Modified Files: win32gui.i Log Message: Return the RECT from DrawText (needed for DT_CALCRECT), some Autoduck fixes Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** win32gui.i 18 May 2005 16:22:57 -0000 1.63 --- win32gui.i 23 May 2005 14:27:58 -0000 1.64 *************** *** 261,264 **** --- 261,267 ---- } + %typemap(python,in) RECT *BOTH = RECT *INPUT; + %typemap(python,argout) RECT *BOTH = RECT *OUTPUT; + %typemap(python,argout) POINT *OUTPUT { PyObject *o; *************** *** 1003,1007 **** // @pyswig int|CreateFontIndirect|function creates a logical font that has the specified characteristics. // The font can subsequently be selected as the current font for any device context. ! HFONT CreateFontIndirect(LOGFONT *lf); %{ --- 1006,1010 ---- // @pyswig int|CreateFontIndirect|function creates a logical font that has the specified characteristics. // The font can subsequently be selected as the current font for any device context. ! HFONT CreateFontIndirect(LOGFONT *lf); // @pyparm <o PyLOGFONT>|lplf||A LOGFONT object as returned by <om win32gui.LOGFONT> %{ *************** *** 2964,2973 **** // @pyswig |DrawFocusRect| BOOLAPI DrawFocusRect(HDC hDC, RECT *INPUT); ! // @pyswig |DrawText| ! int DrawText(HDC hDC, LPCTSTR lpString, int nCount, RECT *INPUT, UINT uFormat); ! // @pyswig |SetTextColor| ! int SetTextColor(HDC hdc, COLORREF color); ! // @pyswig |SetBkMode| ! int SetBkMode(HDC hdc, int mode); // @pyswig |DrawEdge| BOOLAPI DrawEdge(HDC hdc, RECT *INPUT, UINT edge, UINT grfFlags); --- 2967,2992 ---- // @pyswig |DrawFocusRect| BOOLAPI DrawFocusRect(HDC hDC, RECT *INPUT); ! ! // @pyswig (int, RECT)|DrawText|Draws formatted text on a device context ! // @rdesc Returns the height of the drawn text, and the rectangle coordinates ! int DrawText( ! HDC hDC, // @pyparm int/<o PyHANDLE>|hDC||The device context on which to draw ! LPCTSTR lpString, // @pyparm str|String||The text to be drawn ! int nCount, // @pyparm int|nCount||The number of characters, use -1 for simple null-terminated string ! RECT *BOTH, // @pyparm tuple|Rect||Tuple of 4 ints specifying the position (left, top, right, bottom) ! UINT uFormat); // @pyparm int|Format||Formatting flags, combination of win32con.DT_* values ! ! // @pyswig int|SetTextColor|Changes the text color for a device context ! // @rdesc Returns the previous color, or CLR_INVALID on failure ! int SetTextColor( ! HDC hdc, // @pyparm int|hdc||Handle to a device context ! COLORREF color); // @pyparm int|color||The RGB color value - see <om win32api.RGB> ! ! // @pyswig int|SetBkMode|Sets the background mode for a device context ! // @rdesc Returns the previous mode, or 0 on failure ! int SetBkMode( ! HDC hdc, // @pyparm int/<o PyHANDLE>|hdc||Handle to a device context ! int mode); // @pyparm int|BkMode||OPAQUE or TRANSPARENT ! // @pyswig |DrawEdge| BOOLAPI DrawEdge(HDC hdc, RECT *INPUT, UINT edge, UINT grfFlags); |
From: Roger U. <ru...@us...> - 2005-05-23 14:03:56
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22648/win32/Demos Modified Files: print_desktop.py Log Message: Add some of the GDI text drawing functions Index: print_desktop.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/print_desktop.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** print_desktop.py 18 May 2005 16:41:52 -0000 1.2 --- print_desktop.py 23 May 2005 14:03:47 -0000 1.3 *************** *** 1,3 **** ! import win32print, pywintypes, win32con, win32gui, win32ui pname=win32print.GetDefaultPrinter() --- 1,3 ---- ! import win32print, pywintypes, win32con, win32gui, win32ui, win32api pname=win32print.GetDefaultPrinter() *************** *** 40,43 **** --- 40,56 ---- win32gui.StretchBlt(pDC, 0, 0, int(printerwidth*.9), int(printerheight*.9), pcDC, 0, 0, printerwidth, printerheight, win32con.SRCCOPY) + font=win32gui.LOGFONT() + font.lfHeight=int(printerheight/20) + font.lfWidth=font.lfHeight + font.lfWeight=150 + font.lfItalic=1 + font.lfUnderline=1 + hf=win32gui.CreateFontIndirect(font) + win32gui.SelectObject(pDC,hf) + win32gui.SetBkMode(pDC, win32con.TRANSPARENT) + win32gui.SetTextColor(pDC,win32api.RGB(0,255,0)) + win32gui.DrawText(pDC,'Printed by Python!', -1, + (0,0, int(printerwidth*.9), int(printerheight*.9)), + win32con.DT_RIGHT|win32con.DT_BOTTOM|win32con.DT_SINGLELINE) win32print.EndPage(pDC) win32print.EndDoc(pDC) |
From: Mark H. <mha...@us...> - 2005-05-20 23:28:03
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27304 Modified Files: scriptdispatch.py Log Message: Check for newly added named items before handling a call on our IDispatch object. Index: scriptdispatch.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/scriptdispatch.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** scriptdispatch.py 11 Apr 2005 13:04:41 -0000 1.3 --- scriptdispatch.py 20 May 2005 23:27:54 -0000 1.4 *************** *** 30,33 **** --- 30,36 ---- def _dynamic_(self, name, lcid, wFlags, args): + # Ensure any newly added items are available. + self.engine.RegisterNewNamedItems() + self.engine.ProcessNewNamedItemsConnections() if wFlags & pythoncom.INVOKE_FUNC: # attempt to call a function |
From: Mark H. <mha...@us...> - 2005-05-20 23:27:02
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26897 Modified Files: ErrorUtils.cpp Log Message: Clear all elements of the EXCEPINFO structure before filling it. This prevents garbage being seen by the callers of Python COM objects. Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ErrorUtils.cpp 28 Feb 2005 00:08:36 -0000 1.25 --- ErrorUtils.cpp 20 May 2005 23:26:53 -0000 1.26 *************** *** 18,22 **** LPCSTR GetFacilityString(SCODE sc); - static const EXCEPINFO nullExcepInfo = { 0 }; static PyObject *PyCom_PyObjectFromIErrorInfo(IErrorInfo *, HRESULT errorhr); --- 18,21 ---- *************** *** 42,46 **** } PyObject *exception, *v, *tb; - *pExcepInfo = nullExcepInfo; PyErr_Fetch(&exception, &v, &tb); if (PyCom_ExcepInfoFromPyObject(v, pExcepInfo, NULL)) --- 41,44 ---- *************** *** 50,53 **** --- 48,52 ---- else { + memset(pExcepInfo, 0, sizeof(EXCEPINFO)); // Clear the exception raised by PyCom_ExcepInfoFromPyObject, // not the one we are interested in! *************** *** 100,103 **** --- 99,103 ---- assert(v != NULL); assert(pExcepInfo != NULL); + memset(pExcepInfo, 0, sizeof(EXCEPINFO)); PyObject *ob = PyObject_GetAttrString(v, "description"); *************** *** 192,195 **** --- 192,196 ---- return FALSE; } + // It is a COM exception, but may be a server or client instance. // Explicit check for client. *************** *** 200,204 **** (PyInstance_Check(v) && // Class exceptions (PyObject *)(((PyInstanceObject *)v)->in_class)==PyWinExc_COMError) ) { ! // Client side error - use abstract API to get at details. PyObject *ob; if (phresult) { --- 201,208 ---- (PyInstance_Check(v) && // Class exceptions (PyObject *)(((PyInstanceObject *)v)->in_class)==PyWinExc_COMError) ) { ! // Client side error ! // Clear the state of the excep info. ! // use abstract API to get at details. ! memset(pExcepInfo, 0, sizeof(EXCEPINFO)); PyObject *ob; if (phresult) { |
From: Mark H. <mha...@us...> - 2005-05-20 23:26:09
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26502 Modified Files: PyIDataObject.cpp PySTGMEDIUM.cpp Log Message: Explicitly set to zero our STGMEDIUM, and check ones passed to us. Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PySTGMEDIUM.cpp 12 Jun 2004 13:31:50 -0000 1.5 --- PySTGMEDIUM.cpp 20 May 2005 23:25:49 -0000 1.6 *************** *** 138,142 **** BOOL PySTGMEDIUM::CopyTo(STGMEDIUM *pDest) { ! assert(pDest->tymed==0); switch (medium.tymed) { // we can't just copy these handles, and there is no easy way I see --- 138,143 ---- BOOL PySTGMEDIUM::CopyTo(STGMEDIUM *pDest) { ! // caller is responsible for ensuring this is clean. ! assert(pDest->tymed==0 && pDest->pUnkForRelease==0 && pDest->hGlobal == 0); switch (medium.tymed) { // we can't just copy these handles, and there is no easy way I see Index: PyIDataObject.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIDataObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyIDataObject.cpp 12 Jun 2004 13:31:50 -0000 1.5 --- PyIDataObject.cpp 20 May 2005 23:25:49 -0000 1.6 *************** *** 322,325 **** --- 322,327 ---- /* [out] */ STGMEDIUM * pmedium) { + if (!pmedium) + return E_POINTER; PY_GATEWAY_METHOD; PyObject *obpformatetcIn = PyObject_FromFORMATETC(pformatetcIn); *************** *** 332,335 **** --- 334,340 ---- if (PySTGMEDIUM_Check(result)) { PySTGMEDIUM *pym = (PySTGMEDIUM *)result; + // Documentation says pmedium is 'out' - generally it will have empty + // data, but not always. + memset(pmedium, 0, sizeof(*pmedium)); pym->CopyTo(pmedium); } |
From: Mark H. <mha...@us...> - 2005-05-20 23:23:40
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25968 Modified Files: adsicon.py Log Message: Add a few missing constants. Index: adsicon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/adsicon.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** adsicon.py 24 Sep 2004 07:28:02 -0000 1.1 --- adsicon.py 20 May 2005 23:23:31 -0000 1.2 *************** *** 246,247 **** --- 246,278 ---- S_ADS_NOMORE_COLUMNS = _HRESULT_TYPEDEF_(0x00005013L) E_ADS_INVALID_FILTER = _HRESULT_TYPEDEF_((-2147463148)) + + # ADS_DEREFENUM enum + ADS_DEREF_NEVER = 0 + ADS_DEREF_SEARCHING = 1 + ADS_DEREF_FINDING = 2 + ADS_DEREF_ALWAYS = 3 + + # ADS_PREFERENCES_ENUM + ADSIPROP_ASYNCHRONOUS = 0 + ADSIPROP_DEREF_ALIASES = 0x1 + ADSIPROP_SIZE_LIMIT = 0x2 + ADSIPROP_TIME_LIMIT = 0x3 + ADSIPROP_ATTRIBTYPES_ONLY = 0x4 + ADSIPROP_SEARCH_SCOPE = 0x5 + ADSIPROP_TIMEOUT = 0x6 + ADSIPROP_PAGESIZE = 0x7 + ADSIPROP_PAGED_TIME_LIMIT = 0x8 + ADSIPROP_CHASE_REFERRALS = 0x9 + ADSIPROP_SORT_ON = 0xa + ADSIPROP_CACHE_RESULTS = 0xb + ADSIPROP_ADSIFLAG = 0xc + + # ADSI_DIALECT_ENUM + ADSI_DIALECT_LDAP = 0 + ADSI_DIALECT_SQL = 0x1 + + # ADS_CHASE_REFERRALS_ENUM + ADS_CHASE_REFERRALS_NEVER = 0 + ADS_CHASE_REFERRALS_SUBORDINATE = 0x20 + ADS_CHASE_REFERRALS_EXTERNAL = 0x40 + ADS_CHASE_REFERRALS_ALWAYS = ADS_CHASE_REFERRALS_SUBORDINATE | ADS_CHASE_REFERRALS_EXTERNAL |
From: Mark H. <mha...@us...> - 2005-05-20 23:23:13
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25733 Modified Files: ifiltercon.py Log Message: A couple of new constants. Index: ifiltercon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/ifiltercon.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ifiltercon.py 22 Jun 2004 00:53:54 -0000 1.1 --- ifiltercon.py 20 May 2005 23:22:59 -0000 1.2 *************** *** 11,17 **** --- 11,19 ---- IFILTER_INIT_CANON_SPACES = 8 IFILTER_INIT_APPLY_INDEX_ATTRIBUTES = 16 + IFILTER_INIT_APPLY_CRAWL_ATTRIBUTES = 256 IFILTER_INIT_APPLY_OTHER_ATTRIBUTES = 32 IFILTER_INIT_INDEXING_ONLY = 64 IFILTER_INIT_SEARCH_LINKS = 128 + IFILTER_INIT_FILTER_OWNED_VALUE_OK = 512 IFILTER_FLAGS_OLE_PROPERTIES = 1 |
From: Roger U. <ru...@us...> - 2005-05-18 16:42:01
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31531/win32/Demos Modified Files: print_desktop.py Log Message: Remove hardcoded print processor name and add an extra CreateCompatibleDC so demo works with more types of printers, use API functions instead of MFC object methods Index: print_desktop.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/print_desktop.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** print_desktop.py 12 Sep 2004 23:02:32 -0000 1.1 --- print_desktop.py 18 May 2005 16:41:52 -0000 1.2 *************** *** 1,3 **** ! import win32print, pywintypes, win32con, win32ui, win32gui pname=win32print.GetDefaultPrinter() --- 1,3 ---- ! import win32print, pywintypes, win32con, win32gui, win32ui pname=win32print.GetDefaultPrinter() *************** *** 5,9 **** p=win32print.OpenPrinter(pname) print 'Printer handle: ',p ! ## call with last parm set to 0 to get total size needed for printer's DEVMODE dmsize=win32print.DocumentProperties(0, p, pname, None, None, 0) --- 5,9 ---- p=win32print.OpenPrinter(pname) print 'Printer handle: ',p ! print_processor=win32print.GetPrinter(p,2)['pPrintProcessor'] ## call with last parm set to 0 to get total size needed for printer's DEVMODE dmsize=win32print.DocumentProperties(0, p, pname, None, None, 0) *************** *** 16,39 **** win32print.DocumentProperties(0, p, pname, dm, dm, win32con.DM_IN_BUFFER|win32con.DM_OUT_BUFFER) ! pDC=win32gui.CreateDC('WINSPOOL',pname,dm) ! printerDC=win32ui.CreateDCFromHandle(pDC) ! ! printerwidth=printerDC.GetDeviceCaps(110) ##PHYSICALWIDTH ! printerheight=printerDC.GetDeviceCaps(111) ##PHYSICALHEIGHT hwnd=win32gui.GetDesktopWindow() - ## hwnd=win32gui.GetForegroundWindow() l,t,r,b=win32gui.GetWindowRect(hwnd) desktopheight=b-t desktopwidth=r-l dDC = win32gui.GetWindowDC(hwnd) - desktopDC=win32ui.CreateDCFromHandle(dDC) ! printerDC.StartDoc('desktop.bmp') ! printerDC.StartPage() ! printerDC.StretchBlt((0,0),(int(printerwidth*.9),int(printerheight*.9)), ## allow for paper margin ! desktopDC,(0,0),(desktopwidth,desktopheight),win32con.SRCCOPY) ! printerDC.EndPage() ! printerDC.EndDoc() --- 16,51 ---- win32print.DocumentProperties(0, p, pname, dm, dm, win32con.DM_IN_BUFFER|win32con.DM_OUT_BUFFER) ! pDC=win32gui.CreateDC(print_processor,pname,dm) ! printerwidth=win32ui.GetDeviceCaps(pDC, 110) ##PHYSICALWIDTH ! printerheight=win32ui.GetDeviceCaps(pDC, 111) ##PHYSICALHEIGHT hwnd=win32gui.GetDesktopWindow() l,t,r,b=win32gui.GetWindowRect(hwnd) desktopheight=b-t desktopwidth=r-l dDC = win32gui.GetWindowDC(hwnd) ! dcDC=win32gui.CreateCompatibleDC(dDC) ! dcBM = win32gui.CreateCompatibleBitmap(dDC, desktopwidth, desktopheight); ! win32gui.SelectObject(dcDC, dcBM) ! win32gui.StretchBlt(dcDC, 0, 0, desktopwidth, desktopheight, dDC, 0, 0, desktopwidth, desktopheight, win32con.SRCCOPY) ! ! pcDC=win32gui.CreateCompatibleDC(pDC) ! pcBM=win32gui.CreateCompatibleBitmap(pDC, printerwidth, printerheight) ! win32gui.SelectObject(pcDC, pcBM) ! win32gui.StretchBlt(pcDC, 0, 0, printerwidth, printerheight, dcDC, 0, 0, desktopwidth, desktopheight, win32con.SRCCOPY) ! ! win32print.StartDoc(pDC,('desktop.bmp',None,None,0)) ! win32print.StartPage(pDC) ! win32gui.StretchBlt(pDC, 0, 0, int(printerwidth*.9), int(printerheight*.9), pcDC, 0, 0, printerwidth, printerheight, win32con.SRCCOPY) ! ! win32print.EndPage(pDC) ! win32print.EndDoc(pDC) ! ! win32print.ClosePrinter(p) ! win32gui.DeleteDC(dDC) ! win32gui.DeleteDC(dcDC) ! win32gui.DeleteDC(pDC) ! win32gui.DeleteDC(pcDC) |
From: Roger U. <ru...@us...> - 2005-05-18 16:23:29
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27576/win32/src Modified Files: win32gui.i Log Message: Add GetObjectType, some autoduck fixes Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** win32gui.i 12 Apr 2005 08:03:36 -0000 1.62 --- win32gui.i 18 May 2005 16:22:57 -0000 1.63 *************** *** 1033,1036 **** --- 1033,1053 ---- %{ + // @pyswig int|GetObjectType|Returns the type (OBJ_* constant) of a GDI handle + static PyObject *PyGetObjectType(PyObject *self, PyObject *args) + { + HANDLE h; + DWORD t; + // @pyparm int|h||A handle to a GDI object + if (!PyArg_ParseTuple(args, "l:GetObjectType", &h)) + return NULL; + t=GetObjectType(h); + if (t==0) + return PyWin_SetAPIError("GetObjectType"); + return PyLong_FromUnsignedLong(t); + } + %} + %native (GetObjectType) PyGetObjectType; + + %{ // @pyswig object|PyMakeBuffer|Returns a buffer object from addr,len or just len static PyObject *PyMakeBuffer(PyObject *self, PyObject *args) *************** *** 1992,1996 **** HDC hdcDest, // @pyparm int|hdcDest||handle to destination DC int nXDest, // @pyparm int|x||x-coord of destination upper-left corner ! int nYDest, // @pyparm int|t||y-coord of destination upper-left corner int nWidth, // @pyparm int|width||width of destination rectangle int nHeight, // @pyparm int|height||height of destination rectangle --- 2009,2013 ---- HDC hdcDest, // @pyparm int|hdcDest||handle to destination DC int nXDest, // @pyparm int|x||x-coord of destination upper-left corner ! int nYDest, // @pyparm int|y||y-coord of destination upper-left corner int nWidth, // @pyparm int|width||width of destination rectangle int nHeight, // @pyparm int|height||height of destination rectangle *************** *** 2005,2019 **** // destination rectangle, if necessary BOOLAPI StretchBlt( ! HDC hdcDest, // handle to destination DC ! int nXOriginDest, // x-coord of destination upper-left corner ! int nYOriginDest, // y-coord of destination upper-left corner ! int nWidthDest, // width of destination rectangle ! int nHeightDest, // height of destination rectangle ! HDC hdcSrc, // handle to source DC ! int nXOriginSrc, // x-coord of source upper-left corner ! int nYOriginSrc, // y-coord of source upper-left corner ! int nWidthSrc, // width of source rectangle ! int nHeightSrc, // height of source rectangle ! DWORD dwRop // raster operation code ); --- 2022,2036 ---- // destination rectangle, if necessary BOOLAPI StretchBlt( ! HDC hdcDest, // @pyparm int|hdcDest||handle to destination DC ! int nXOriginDest, // @pyparm int|x||x-coord of destination upper-left corner ! int nYOriginDest, // @pyparm int|y||y-coord of destination upper-left corner ! int nWidthDest, // @pyparm int|width||width of destination rectangle ! int nHeightDest, // @pyparm int|height||height of destination rectangle ! HDC hdcSrc, // @pyparm int|hdcSrc||handle to source DC ! int nXOriginSrc, // @pyparm int|nXSrc||x-coord of source upper-left corner ! int nYOriginSrc, // @pyparm int|nYSrc||y-coord of source upper-left corner ! int nWidthSrc, // @pyparm int|nWidthSrc||width of source rectangle ! int nHeightSrc, // @pyparm int|nHeightSrc||height of source rectangle ! DWORD dwRop // @pyparm int|dwRop||raster operation code ); |
From: Mark H. <mha...@us...> - 2005-05-18 02:38:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21258 Modified Files: win32pipe.i Log Message: SetNamedPipeState now allows None for any of the last 3 params Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32pipe.i 30 Jan 2005 13:39:26 -0000 1.11 --- win32pipe.i 18 May 2005 02:38:49 -0000 1.12 *************** *** 217,236 **** unsigned long MaxCollectionCount; unsigned long CollectDataTimeout; PyObject *obhNamedPipe; // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. ! // @pyparm int|Mode||The pipe read mode. ! // @pyparm int|MaxCollectionCount||Maximum bytes collected before transmission to the server. ! // @pyparm int|CollectDataTimeout||Maximum time to wait, in milliseconds, before transmission to server. ! if (!PyArg_ParseTuple(args, "Oiii:SetNamedPipeHandleState", ! &obhNamedPipe, &Mode, ! &MaxCollectionCount, &CollectDataTimeout)) return NULL; if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) return NULL; ! if (!SetNamedPipeHandleState(hNamedPipe, &Mode, &MaxCollectionCount, ! &CollectDataTimeout)) return PyWin_SetAPIError("SetNamedPipeHandleState"); Py_INCREF(Py_None); --- 217,258 ---- unsigned long MaxCollectionCount; unsigned long CollectDataTimeout; + unsigned long *pMaxCollectionCount = NULL; + unsigned long *pCollectDataTimeout = NULL; + unsigned long *pMode = NULL; PyObject *obhNamedPipe; + PyObject *obMode, *obMaxCollectionCount, *obCollectDataTimeout; // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. ! // @pyparm int/None|Mode||The pipe read mode. ! // @pyparm int/None|MaxCollectionCount||Maximum bytes collected before transmission to the server. ! // @pyparm int/None|CollectDataTimeout||Maximum time to wait, in milliseconds, before transmission to server. ! if (!PyArg_ParseTuple(args, "OOOO:SetNamedPipeHandleState", ! &obhNamedPipe, &obMode, ! &obMaxCollectionCount, &obCollectDataTimeout)) return NULL; if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) return NULL; + if (obMode!=Py_None) { + if (!PyInt_Check(obMode)) + return PyErr_Format(PyExc_TypeError, "mode param must be None or an integer (got %s)", obMode->ob_type->tp_name); + Mode = PyInt_AsLong(obMode); + pMode = &Mode; + } + if (obMaxCollectionCount!=Py_None) { + if (!PyInt_Check(obMaxCollectionCount)) + return PyErr_Format(PyExc_TypeError, "maxCollectionCount param must be None or an integer (got %s)", obMaxCollectionCount->ob_type->tp_name); + MaxCollectionCount = PyInt_AsLong(obMaxCollectionCount); + pMaxCollectionCount = &MaxCollectionCount; + } + if (obCollectDataTimeout!=Py_None) { + if (!PyInt_Check(obCollectDataTimeout)) + return PyErr_Format(PyExc_TypeError, "collectDataTimeout param must be None or an integer (got %s)", obCollectDataTimeout->ob_type->tp_name); + CollectDataTimeout = PyInt_AsLong(obCollectDataTimeout); + pCollectDataTimeout = &CollectDataTimeout; + } ! if (!SetNamedPipeHandleState(hNamedPipe, pMode, pMaxCollectionCount, ! pCollectDataTimeout)) return PyWin_SetAPIError("SetNamedPipeHandleState"); Py_INCREF(Py_None); |
From: Roger U. <ru...@us...> - 2005-05-16 07:54:13
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11604/com/win32comext/shell/demos Added Files: viewstate.py Log Message: Demo for SHGetViewStatePropertyBag --- NEW FILE: viewstate.py --- """ Demonstrates how to propagate a folder's view state to all its subfolders The format of the ColInfo stream is apparently undocumented, but it can be read raw from one folder and copied to another's view state. """ from win32com.shell import shell, shellcon import pythoncom import os, sys template_folder=os.path.split(sys.executable)[0] print 'Template folder:', template_folder template_pidl=shell.SHILCreateFromPath(template_folder,0)[0] template_pb=shell.SHGetViewStatePropertyBag(template_pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag) # Column info has to be read as a stream # This may blow up if folder has never been opened in Explorer and has no ColInfo yet template_iunk=template_pb.Read('ColInfo',pythoncom.VT_UNKNOWN) template_stream=template_iunk.QueryInterface(pythoncom.IID_IStream) streamsize=template_stream.Stat()[2] template_colinfo=template_stream.Read(streamsize) def update_colinfo(not_used, dir_name, fnames): for fname in fnames: full_fname=os.path.join(dir_name,fname) if os.path.isdir(full_fname): print full_fname pidl=shell.SHILCreateFromPath(full_fname,0)[0] pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag) ## not all folders already have column info, and we're replacing it anyway pb.Write('ColInfo', template_stream) iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN) s=iunk.QueryInterface(pythoncom.IID_IStream) s.Write(template_colinfo) s=None ## attribute names read from registry, can't find any way to enumerate IPropertyBag for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'): pb.Write(attr, template_pb.Read(attr)) pb=None os.path.walk(template_folder,update_colinfo,None) |
From: Roger U. <ru...@us...> - 2005-05-12 19:29:15
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17277/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Add SHQueryRecycleBin SHGetFolderLocation loads from shell32.dll instead of shfolder.dll Add service GUID's for IServiceProvider.QueryService Load function pointers in module init Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** shell.cpp 13 Feb 2005 12:23:29 -0000 1.35 --- shell.cpp 12 May 2005 19:28:59 -0000 1.36 *************** *** 41,44 **** --- 41,65 ---- #define OleSetOleError PyCom_BuildPyException + static HMODULE shell32 = NULL; + static HMODULE shfolder = NULL; + + typedef BOOL (WINAPI * PFNSHGetSpecialFolderPath)(HWND, LPWSTR, int, BOOL ); + static PFNSHGetSpecialFolderPath pfnSHGetSpecialFolderPath = NULL; + + typedef HRESULT (WINAPI * PFNSHGetFolderLocation)(HWND, int, HANDLE, DWORD, LPITEMIDLIST *); + static PFNSHGetFolderLocation pfnSHGetFolderLocation = NULL; + + typedef HRESULT (WINAPI * PFNSHEmptyRecycleBin)(HWND, LPSTR, DWORD ); + static PFNSHEmptyRecycleBin pfnSHEmptyRecycleBin = NULL; + + typedef void (WINAPI * PFNSHGetSettings)(LPSHELLFLAGSTATE, DWORD); + static PFNSHGetSettings pfnSHGetSettings = NULL; + + typedef HRESULT (WINAPI * PFNSHGetFolderPath)(HWND, int, HANDLE, DWORD, LPWSTR); + static PFNSHGetFolderPath pfnSHGetFolderPath = NULL; + + typedef HRESULT (WINAPI *PFNSHQueryRecycleBin)(LPCWSTR, LPSHQUERYRBINFO); + static PFNSHQueryRecycleBin pfnSHQueryRecycleBin = NULL; + void PyShell_FreeMem(void *p) { *************** *** 985,996 **** return NULL; - typedef BOOL (WINAPI * PFNSHGetSpecialFolderPath)(HWND, LPWSTR, int, BOOL ); - // @comm This method is only available in shell version 4.71. If the // function is not available, a COM Exception with HRESULT=E_NOTIMPL // will be raised. If the function fails, a COM Exception with // HRESULT=E_FAIL will be raised. - HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); - PFNSHGetSpecialFolderPath pfnSHGetSpecialFolderPath = (PFNSHGetSpecialFolderPath)GetProcAddress(hmod, "SHGetSpecialFolderPathW"); if (pfnSHGetSpecialFolderPath==NULL) return OleSetOleError(E_NOTIMPL); --- 1006,1013 ---- *************** *** 1093,1106 **** return NULL; ! typedef HRESULT (WINAPI * PFNSHGetFolderPath)(HWND, int, HANDLE, DWORD, LPWSTR); ! ! // @comm This method is only available if you have shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary(TEXT("shfolder.dll")); ! PFNSHGetFolderPath pfnSHGetFolderPath = NULL; ! if (hmod) pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(hmod, "SHGetFolderPathW"); ! if (pfnSHGetFolderPath==NULL) { ! if (hmod) FreeLibrary(hmod); return OleSetOleError(E_NOTIMPL); - } WCHAR buf[MAX_PATH+1]; --- 1110,1116 ---- return NULL; ! // @comm This method is only available with later versions of shell32.dll, or if you have shfolder.dll installed on earlier systems ! if (pfnSHGetFolderPath==NULL) return OleSetOleError(E_NOTIMPL); WCHAR buf[MAX_PATH+1]; *************** *** 1109,1113 **** PY_INTERFACE_POSTCALL; - FreeLibrary(hmod); if (FAILED(hr)) return OleSetOleError(hr); --- 1119,1122 ---- *************** *** 1119,1153 **** { HWND hwndOwner; int nFolder; ! long flags = 0; ! PyObject *obHandle; ! BOOL bCreate = FALSE; ! if(!PyArg_ParseTuple(args, "liO|l:SHGetFolderLocation", ! &hwndOwner, // @pyparm int|hwndOwner|| &nFolder, // @pyparm int|nFolder||One of the CSIDL_* constants specifying the path. ! &obHandle, // @pyparm <o PyHANDLE>|handle||An access token that can be used to represent a particular user, or None ! &flags)) // @pyparm int|reserved||Must be 0 return NULL; ! ! HANDLE handle; ! if (!PyWinObject_AsHANDLE(obHandle, &handle, TRUE)) return NULL; - LPITEMIDLIST pidl; ! typedef HRESULT (WINAPI * PFNSHGetFolderLocation)(HWND, int, LPITEMIDLIST *); ! ! // @comm This method is only available if you have a late version of shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary(TEXT("shfolder.dll")); ! PFNSHGetFolderLocation pfnSHGetFolderLocation = NULL; ! if (hmod) pfnSHGetFolderLocation=(PFNSHGetFolderLocation)GetProcAddress(hmod, "SHGetFolderLocationW"); ! if (pfnSHGetFolderLocation==NULL) { ! if (hmod) FreeLibrary(hmod); return OleSetOleError(E_NOTIMPL); - } PY_INTERFACE_PRECALL; ! HRESULT hr = (*pfnSHGetFolderLocation)(hwndOwner, nFolder, &pidl); PY_INTERFACE_POSTCALL; ! FreeLibrary(hmod); if (FAILED(hr)) return OleSetOleError(hr); --- 1128,1153 ---- { HWND hwndOwner; + HANDLE hToken=NULL; int nFolder; ! DWORD flags = 0; ! PyObject *obToken=Py_None; ! ! if(!PyArg_ParseTuple(args, "li|Ol:SHGetFolderLocation", ! &hwndOwner, // @pyparm int|hwndOwner||Window in which to display any neccessary dialogs &nFolder, // @pyparm int|nFolder||One of the CSIDL_* constants specifying the path. ! &obToken, // @pyparm <o PyHANDLE>|hToken|None|An access token that can be used to represent a particular user, or None ! &flags)) // @pyparm int|reserved|0|Must be 0 return NULL; ! if (!PyWinObject_AsHANDLE(obToken, &hToken, TRUE)) return NULL; LPITEMIDLIST pidl; ! // @comm This method is only available with version 5 or later of the shell controls ! if (pfnSHGetFolderLocation==NULL) return OleSetOleError(E_NOTIMPL); PY_INTERFACE_PRECALL; ! HRESULT hr = (*pfnSHGetFolderLocation)(hwndOwner, nFolder, hToken, flags, &pidl); PY_INTERFACE_POSTCALL; ! if (FAILED(hr)) return OleSetOleError(hr); *************** *** 1186,1193 **** return NULL; - typedef HRESULT (WINAPI * PFNSHEmptyRecycleBin)(HWND, LPSTR, DWORD ); // @comm This method is only available in shell version 4.71. If the function is not available, a COM Exception with HRESULT=E_NOTIMPL will be raised. - HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); - PFNSHEmptyRecycleBin pfnSHEmptyRecycleBin = (PFNSHEmptyRecycleBin)GetProcAddress(hmod, "SHEmptyRecycleBinA"); if (pfnSHEmptyRecycleBin==NULL) return OleSetOleError(E_NOTIMPL); --- 1186,1190 ---- *************** *** 1202,1205 **** --- 1199,1224 ---- } + // @pymethod long,long|shell|SHQueryRecycleBin|Retrieves the total size and number of items in the Recycle Bin for a specified drive + static PyObject *PySHQueryRecycleBin(PyObject *self, PyObject *args) + { + PyObject *obRootPath=Py_None; + HRESULT hr; + WCHAR *RootPath=NULL; + SHQUERYRBINFO info; + if (!PyArg_ParseTuple(args, "|O:SHQueryRecycleBin", + &obRootPath)) // @pyparm <o PyUnicode>|RootPath|None|A path containing the drive whose recycle bin will be queried, or None for all drives + return NULL; + if (!PyWinObject_AsWCHAR(obRootPath, &RootPath, TRUE)) + return NULL; + if (pfnSHQueryRecycleBin==NULL) + return OleSetOleError(E_NOTIMPL); + info.cbSize=sizeof(SHQUERYRBINFO); + hr=(*pfnSHQueryRecycleBin)(RootPath, &info); + PyWinObject_FreeWCHAR(RootPath); + if (FAILED(hr)) + return OleSetOleError(hr); + return Py_BuildValue("LL", info.i64Size, info.i64NumItems); + } + // @pymethod int, int|shell|SHFileOperation|Copies, moves, renames, or deletes a file system object. // The result is the int result of the function itself, and the result of the *************** *** 1517,1527 **** return NULL; - typedef void (WINAPI * PFNSHGetSettings)(LPSHELLFLAGSTATE, DWORD); - // @comm This method is only available in shell version 4.71. If the // function is not available, a COM Exception with HRESULT=E_NOTIMPL // will be raised. - HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); - PFNSHGetSettings pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(hmod, "SHGetSettings"); if (pfnSHGetSettings==NULL) return OleSetOleError(E_NOTIMPL); --- 1536,1542 ---- *************** *** 1999,2003 **** { "SHChangeNotify", PySHChangeNotify, 1 }, // @pymeth SHChangeNotify|Notifies the system of an event that an application has performed. An application should use this function if it performs an action that may affect the shell. { "SHEmptyRecycleBin", PySHEmptyRecycleBin, 1 }, // @pymeth SHEmptyRecycleBin|Empties the recycle bin on the specified drive. ! { "SHGetDesktopFolder", PySHGetDesktopFolder, 1}, // @pymeth SHGetDesktopFolder|Retrieves the <o PyIShellFolder> interface for the desktop folder, which is the root of the shell's namespace. { "SHUpdateImage", PySHUpdateImage, 1}, // @pymeth SHUpdateImage|Notifies the shell that an image in the system image list has changed. { "SHChangeNotify", PySHChangeNotify, 1}, // @pymeth SHChangeNotify|Notifies the system of an event that an application has performed. --- 2014,2019 ---- { "SHChangeNotify", PySHChangeNotify, 1 }, // @pymeth SHChangeNotify|Notifies the system of an event that an application has performed. An application should use this function if it performs an action that may affect the shell. { "SHEmptyRecycleBin", PySHEmptyRecycleBin, 1 }, // @pymeth SHEmptyRecycleBin|Empties the recycle bin on the specified drive. ! { "SHQueryRecycleBin", PySHQueryRecycleBin, 1}, // @pymeth SHQueryRecycleBin|Returns the number of items and total size of recycle bin ! { "SHGetDesktopFolder", PySHGetDesktopFolder, 1}, // @pymeth SHGetDesktopFolder|Retrieves the <o PyIShellFolder> interface for the desktop folder, which is the root of the shell's namespace. { "SHUpdateImage", PySHUpdateImage, 1}, // @pymeth SHUpdateImage|Notifies the shell that an image in the system image list has changed. { "SHChangeNotify", PySHChangeNotify, 1}, // @pymeth SHChangeNotify|Notifies the system of an event that an application has performed. *************** *** 2087,2101 **** PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); ADD_CONSTANT(SLR_NO_UI); ADD_CONSTANT(SLR_NOLINKINFO); ADD_CONSTANT(SLR_INVOKE_MSI); ! ADD_CONSTANT(SLR_ANY_MATCH); ! ADD_CONSTANT(SLR_UPDATE); ! ADD_CONSTANT(SLR_NOUPDATE); ADD_CONSTANT(SLR_NOSEARCH); ADD_CONSTANT(SLR_NOTRACK); ! ADD_CONSTANT(SLGP_SHORTPATH); ! ADD_CONSTANT(SLGP_UNCPRIORITY); ! ADD_CONSTANT(SLGP_RAWPATH); ADD_CONSTANT(HOTKEYF_ALT); ADD_CONSTANT(HOTKEYF_CONTROL); --- 2103,2138 ---- PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); + // load dll's and function pointers ahead of time + shell32=GetModuleHandle(TEXT("shell32.dll")); + if (shell32==NULL) + shell32 = LoadLibrary(TEXT("shell32.dll")); + if (shell32!=NULL){ + pfnSHGetFolderLocation=(PFNSHGetFolderLocation)GetProcAddress(shell32, "SHGetFolderLocation"); + pfnSHGetSpecialFolderPath = (PFNSHGetSpecialFolderPath)GetProcAddress(shell32, "SHGetSpecialFolderPathW"); + pfnSHEmptyRecycleBin = (PFNSHEmptyRecycleBin)GetProcAddress(shell32, "SHEmptyRecycleBinA"); + pfnSHQueryRecycleBin = (PFNSHQueryRecycleBin)GetProcAddress(shell32, "SHQueryRecycleBinW"); + pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(shell32, "SHGetSettings"); + pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shell32, "SHGetFolderPathW"); + } + // SHGetFolderPath comes from shfolder.dll on older systems + if (pfnSHGetFolderPath==NULL){ + shfolder = GetModuleHandle(TEXT("shfolder.dll")); + if (shfolder==NULL) + shfolder = LoadLibrary(TEXT("shfolder.dll")); + if (shfolder!=NULL) + pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shfolder, "SHGetFolderPathW"); + } + ADD_CONSTANT(SLR_NO_UI); ADD_CONSTANT(SLR_NOLINKINFO); ADD_CONSTANT(SLR_INVOKE_MSI); ! ADD_CONSTANT(SLR_ANY_MATCH); ! ADD_CONSTANT(SLR_UPDATE); ! ADD_CONSTANT(SLR_NOUPDATE); ADD_CONSTANT(SLR_NOSEARCH); ADD_CONSTANT(SLR_NOTRACK); ! ADD_CONSTANT(SLGP_SHORTPATH); ! ADD_CONSTANT(SLGP_UNCPRIORITY); ! ADD_CONSTANT(SLGP_RAWPATH); ADD_CONSTANT(HOTKEYF_ALT); ADD_CONSTANT(HOTKEYF_CONTROL); *************** *** 2126,2129 **** --- 2163,2174 ---- ADD_IID(CGID_ShellServiceObject); ADD_IID(CGID_ExplorerBarDoc); + ADD_IID(SID_SShellDesktop); + ADD_IID(SID_SUrlHistory); + ADD_IID(SID_SInternetExplorer); + ADD_IID(SID_SWebBrowserApp); + ADD_IID(SID_SProgressUI); + ADD_IID(SID_LinkSite); + ADD_IID(SID_ShellFolderViewCB); + ADD_IID(SID_SShellBrowser); #else # pragma message("Please update your SDK headers - IE5 features missing!") *************** *** 2131,2135 **** #if (_WIN32_IE >= 0x0500) - ADD_IID(FMTID_ShellDetails); ADD_IID(FMTID_Storage); --- 2176,2179 ---- *************** *** 2145,2148 **** --- 2189,2193 ---- ADD_IID(FMTID_MediaFileSummaryInformation); ADD_IID(FMTID_ImageSummaryInformation); + #else # pragma message("Please update your SDK headers - IE5 features missing!") |
From: Mark H. <mha...@us...> - 2005-05-05 01:56:51
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29576 Removed Files: swig.bat Log Message: Remove file no longer needed by the build process. --- swig.bat DELETED --- |
From: Mark H. <mha...@us...> - 2005-05-02 12:19:15
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9163 Modified Files: MANIFEST.in Log Message: Add DirectSource module to the source distribution. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pywin32/pywin32/MANIFEST.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MANIFEST.in 7 Mar 2005 11:52:29 -0000 1.8 --- MANIFEST.in 2 May 2005 12:10:45 -0000 1.9 *************** *** 61,64 **** --- 61,67 ---- include com/win32comext/ifilter/src/*.h include com/win32comext/ifilter/demo/*.py + include com/win32comext/directsound/src/*.h + include com/win32comext/directsound/test/*.py + include com/win32comext/directsound/test/*.wav # Pythonwin |
From: Roger U. <ru...@us...> - 2005-05-02 03:31:20
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28067/win32/src Modified Files: win32apimodule.cpp Log Message: LoadString takes nbr of characters as input instead of nbr of bytes Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** win32apimodule.cpp 5 Mar 2005 04:42:38 -0000 1.47 --- win32apimodule.cpp 2 May 2005 03:31:11 -0000 1.48 *************** *** 3795,3799 **** { HMODULE hModule; ! int numChars = 1024; UINT stringId; if ( !PyArg_ParseTuple(args, "ii|i", --- 3795,3799 ---- { HMODULE hModule; ! int numChars = 1024, gotChars=0; UINT stringId; if ( !PyArg_ParseTuple(args, "ii|i", *************** *** 3802,3817 **** &numChars)) // @pyparm int|numChars|1024|Number of characters to allocate for the return buffer. return NULL; ! UINT numBytes = sizeof(WCHAR) * numChars; WCHAR *buffer = (WCHAR *)malloc(numBytes); ! if (buffer==NULL) { ! PyErr_SetString(PyExc_MemoryError, "Allocating buffer for LoadString"); ! return NULL; ! } ! int gotBytes = LoadStringW(hModule, stringId, buffer, numBytes); PyObject *rc; ! if (gotBytes==0) rc = ReturnAPIError("LoadString"); else ! rc = PyWinObject_FromWCHAR(buffer, gotBytes); free(buffer); return rc; --- 3802,3815 ---- &numChars)) // @pyparm int|numChars|1024|Number of characters to allocate for the return buffer. return NULL; ! int numBytes = sizeof(WCHAR) * numChars; WCHAR *buffer = (WCHAR *)malloc(numBytes); ! if (buffer==NULL) ! return PyErr_Format(PyExc_MemoryError, "Allocating buffer of %d bytes for LoadString", numBytes); ! gotChars = LoadStringW(hModule, stringId, buffer, numChars); PyObject *rc; ! if (gotChars==0) rc = ReturnAPIError("LoadString"); else ! rc = PyWinObject_FromWCHAR(buffer, gotChars); free(buffer); return rc; |
From: Roger U. <ru...@us...> - 2005-05-02 02:57:34
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21354/win32/src Modified Files: win32process.i Log Message: change STARTUPINFO.wShowWindow to T_USHORT Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32process.i 30 Jun 2004 01:51:21 -0000 1.15 --- win32process.i 2 May 2005 02:57:25 -0000 1.16 *************** *** 95,99 **** {"dwFillAttribute", T_INT, OFF(m_startupinfo.dwFillAttribute)}, // @prop integer|dwFillAttribute|Specifies the initial text and background colors if a new console window is created in a console application. These values are ignored in GUI applications {"dwFlags", T_INT, OFF(m_startupinfo.dwFlags)}, // @prop integer|dwFlags|This is a bit field that determines whether certain STARTUPINFO attributes are used when the process creates a window. To use many of the additional attributes, you typically must set the appropriate mask in this attribute, and also set the attributes themselves. Any combination of the win32con.STARTF_* flags can be specified. ! {"wShowWindow", T_INT, OFF(m_startupinfo.wShowWindow)},//@prop integer|wShowWindow|Can be any of the SW_ constants defined in win32con. For GUI processes, this specifies the default value the first time ShowWindow is called. {NULL} }; --- 95,99 ---- {"dwFillAttribute", T_INT, OFF(m_startupinfo.dwFillAttribute)}, // @prop integer|dwFillAttribute|Specifies the initial text and background colors if a new console window is created in a console application. These values are ignored in GUI applications {"dwFlags", T_INT, OFF(m_startupinfo.dwFlags)}, // @prop integer|dwFlags|This is a bit field that determines whether certain STARTUPINFO attributes are used when the process creates a window. To use many of the additional attributes, you typically must set the appropriate mask in this attribute, and also set the attributes themselves. Any combination of the win32con.STARTF_* flags can be specified. ! {"wShowWindow", T_USHORT, OFF(m_startupinfo.wShowWindow)},//@prop integer|wShowWindow|Can be any of the SW_ constants defined in win32con. For GUI processes, this specifies the default value the first time ShowWindow is called. {NULL} }; |
From: Mark H. <mha...@us...> - 2005-04-28 22:42:28
|
Update of /cvsroot/pywin32/pywin32/isapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4827 Modified Files: install.py Log Message: IIS 5.1 may throw an AttributeError rather than a COM error trying to use the "registered extension modules" feature. Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** install.py 17 Feb 2005 05:47:29 -0000 1.4 --- install.py 28 Apr 2005 22:42:19 -0000 1.5 *************** *** 305,309 **** desc) log(2, "Added extension file '%s' (%s)" % (module, desc)) ! except pythoncom.com_error, details: # IIS5 always fails. Probably should upgrade this to # complain more loudly if IIS6 fails. --- 305,309 ---- desc) log(2, "Added extension file '%s' (%s)" % (module, desc)) ! except (pythoncom.com_error, AttributeError), details: # IIS5 always fails. Probably should upgrade this to # complain more loudly if IIS6 fails. *************** *** 332,336 **** ob.DeleteExtensionFileRecord(module) log(2, "Deleted extension file record for '%s'" % module) ! except pythoncom.com_error, details: log(2, "Failed to remove extension file '%s': %s" % (module, details)) --- 332,336 ---- ob.DeleteExtensionFileRecord(module) log(2, "Deleted extension file record for '%s'" % module) ! except (pythoncom.com_error, AttributeError), details: log(2, "Failed to remove extension file '%s': %s" % (module, details)) |