Update of /cvsroot/pywin32/pywin32/win32/src/win32net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19247/win32/src/win32net
Modified Files:
win32net.h win32netmisc.cpp win32netmodule.cpp
Log Message:
Add NetValidateName
Index: win32netmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** win32netmodule.cpp 12 Jun 2004 07:51:53 -0000 1.16
--- win32netmodule.cpp 12 Jan 2005 07:38:20 -0000 1.17
***************
*** 38,41 ****
--- 38,42 ----
#include "assert.h"
+
/*****************************************************************************/
/* error helpers */
***************
*** 1008,1011 ****
--- 1009,1013 ----
extern PyObject * PyNetFileClose(PyObject *self, PyObject *args);
extern PyObject * PyNetFileGetInfo(PyObject *self, PyObject *args);
+ extern PyObject * PyNetValidateName(PyObject *self, PyObject *args);
/* List of functions exported by this module */
***************
*** 1083,1086 ****
--- 1085,1089 ----
{"NetFileGetInfo", PyNetFileGetInfo, 1}, // @pymeth NetFileGetInfo|Get info about files open on the server.
{"NetStatisticsGet", PyNetStatisticsGet, 1}, // @pymeth NetStatisticsGet|Return server or workstation stats
+ {"NetValidateName", PyNetValidateName, 1}, // @pymeth NetValidateName|Verify that computer/domain name is valid for given context
{NULL, NULL}
};
***************
*** 1113,1115 ****
--- 1116,1124 ----
AddConstant(dict, "USE_FORCE", USE_FORCE);
AddConstant(dict, "USE_LOTS_OF_FORCE", USE_LOTS_OF_FORCE);
+
+ HMODULE hmodule=GetModuleHandle(_T("netapi32"));
+ if (hmodule==NULL)
+ hmodule=LoadLibrary(_T("netapi32"));
+ if (hmodule!=NULL)
+ pfnNetValidateName=(NetValidateNamefunc)GetProcAddress(hmodule,"NetValidateName");
}
Index: win32net.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32net.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32net.h 20 Feb 2001 14:35:43 -0000 1.2
--- win32net.h 12 Jan 2005 07:38:10 -0000 1.3
***************
*** 60,61 ****
--- 60,64 ----
PyObject *PyDoGroupDelMembers(PyObject *self, PyObject *args);
+
+ typedef NET_API_STATUS (NET_API_FUNCTION *NetValidateNamefunc)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, NETSETUP_NAME_TYPE);
+ extern NetValidateNamefunc pfnNetValidateName;
Index: win32netmisc.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmisc.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** win32netmisc.cpp 8 Sep 2004 23:28:16 -0000 1.9
--- win32netmisc.cpp 12 Jan 2005 07:38:20 -0000 1.10
***************
*** 1104,1108 ****
}
! // @pymethod (list|win32net|NetServerDiskEnum|Retrieves the list of disk drives on a server.
// @rdesc The result is a list of drives on the server
PyObject *
--- 1104,1108 ----
}
! // @pymethod list|win32net|NetServerDiskEnum|Retrieves the list of disk drives on a server.
// @rdesc The result is a list of drives on the server
PyObject *
***************
*** 1155,1158 ****
--- 1155,1160 ----
}
+ // @pymethod dict|win32net|NetStatisticsGet|Retrieves network statistics for specified service on specified machine
+ // @rdesc The result is a dictionary representing a STAT_SERVER_0 or STAT_WORKSTATION_0 struct
PyObject *
PyNetStatisticsGet(PyObject *self, PyObject *args)
***************
*** 1267,1268 ****
--- 1269,1314 ----
return ret;
}
+
+ extern "C" NetValidateNamefunc pfnNetValidateName=NULL;
+ // @pymethod |win32net|NetValidateName|Checks that domain/machine/workgroup name is valid for given context
+ // @rdesc Returns none if valid, exception if not
+ // @comm If Account and Password aren't passed, current logon credentials are used
+ PyObject *
+ PyNetValidateName(PyObject *self, PyObject *args)
+ {
+ // @pyparm string/<o PyUnicode>|Server||Name of server on which to execute (None or blank uses local)
+ // @pyparm string/<o PyUnicode>|Name||Machine, domain, or workgroup name to validate
+ // @pyparm int|NameType||Type of name to validate - from NETSETUP_NAME_TYPE enum (win32net.NetSetup*)
+ // @pyparm string/<o PyUnicode>|Account|None|Account name to use while validating, current security context is used if not specified
+ // @pyparm string/<o PyUnicode>|Password|None|Password for Account
+ PyObject *obServer, *obName, *obAccount=Py_None, *obPassword=Py_None, *ret=NULL;
+ WCHAR *Server=NULL, *Name=NULL, *Account=NULL, *Password=NULL;
+ NET_API_STATUS err;
+ NETSETUP_NAME_TYPE NameType;
+ if (pfnNetValidateName==NULL){
+ PyErr_SetString(PyExc_NotImplementedError,"NetValidateName does not exist on this platform");
+ return NULL;
+ }
+ if (!PyArg_ParseTuple(args, "OOl|OO",&obServer, &obName, &NameType, &obAccount, &obPassword))
+ return NULL;
+ if (PyWinObject_AsWCHAR(obServer, &Server, TRUE)
+ &&PyWinObject_AsWCHAR(obName, &Name, FALSE)
+ &&PyWinObject_AsWCHAR(obAccount, &Account, TRUE)
+ &&PyWinObject_AsWCHAR(obPassword, &Password, TRUE)){
+ err=(*pfnNetValidateName)(Server, Name, Account, Password, NameType);
+ if (err==NERR_Success)
+ ret=Py_None;
+ else
+ ReturnNetError("NetValidateName", err);
+ }
+ if (Server)
+ PyWinObject_FreeWCHAR(Server);
+ if (Name)
+ PyWinObject_FreeWCHAR(Name);
+ if (Account)
+ PyWinObject_FreeWCHAR(Account);
+ if (Password)
+ PyWinObject_FreeWCHAR(Password);
+ Py_XINCREF(ret);
+ return ret;
+ }
|