join a samba domain

2008-12-22 Thread Toff
hi,

I 'm trying to write a script to make my computer join a samba.

domeone have any idea ??


thanks regards,

*
# -*- coding: iso-8859-1 *-*

import win32com.client
import os,sys
import win32api
import impers
import socket
from win32com.client import GetObject
import wmi

def main():
test()
joindom()
def test():
import wmi
c = wmi.WMI()
os = c.Win32_ComputerSystem
for method_name in os.methods:
  method = getattr(os, method_name)
  print method

def joindom():
#Joining a computer to a domain
#=
JOIN_DOMAIN = 1
ACCT_CREATE = 2
ACCT_DELETE = 4
WIN9X_UPGRADE   = 16
DOMAIN_JOIN_IF_JOINED   = 32
JOIN_UNSECURE   = 64
MACHINE_PASSWORD_PASSED = 128
DEFERRED_SPN_SET= 256
INSTALL_INVOCATION  = 262144
strDomain   = "mydom"
strPassword = "mydompw"
strUser = "admin"

strComputer = socket.gethostname()
print strComputer
#objComputer = win32com.client.GetObject(r"winmgmts:
{impersonationLevel=Impersonate}!\\mypc\root
\cimv2:Win32_ComputerSystem.Name='mypc'")
import wmi
c = wmi.WMI()
d = c.Win32_ComputerSystem
d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")


if __name__=='__main__':
  main()
***
--
http://mail.python.org/mailman/listinfo/python-list


Re: join a samba domain

2008-12-22 Thread Toff
On 22 déc, 17:02, Tim Golden  wrote:
> Toff wrote:
> > hi,
>
> > I 'm trying to write a script to make my computer join a samba.
>
> > domeone have any idea ??
>
> Ummm. It's not clear if you're saying that your code doesn't
> work, or asking for general advice, or what? I'm not in a
> position to have my machine join a domain or workgroup, but
> you seem to have got most things in place already. The only
> thing I would expect to have to change is this last line:
>
> >    import wmi
> >    c = wmi.WMI()
> >    d = c.Win32_ComputerSystem
> >    d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
>
> because the d is only a WMI *class*, not a WMI *instance*,
> so doesn't refer as it should to your computer system but
> to the class of computer systems. Try something like this (untested):
>
> 
> import wmi
>
> c = wmi.WMI ()
> for d in c.Win32_ComputerSystem ():
>   d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
>
> 
>
> TJG
thanks but it doesn't work
I've got this errors

Traceback (most recent call last):
 File "integrdom.py", line 51, in 
   main()
 File "integrdom.py", line 13, in main
   joindom()
 File "integrdom.py", line 44, in joindom
   d.JoinDomainOrWorkGroup(None, 3, "domcd", "adminLocal", r"admin
\domcd")
 File "c:\Python25\Lib\site-packages\wmi.py", line 493, in __getattr__
   handle_com_error (error_info)
 File "c:\Python25\Lib\site-packages\wmi.py", line 189, in
handle_com_error
   raise x_wmi, "\n".join (exception_string)
wmi.x_wmi

--
http://mail.python.org/mailman/listinfo/python-list


Re: join a samba domain

2008-12-22 Thread Toff
On 22 déc, 17:57, Tim Golden  wrote:
> Toff wrote:
> > On 22 déc, 17:02, Tim Golden  wrote:
> >> Toff wrote:
> >>> hi,
> >>> I 'm trying to write a script to make my computer join a samba.
> >>> domeone have any idea ??
> >> Ummm. It's not clear if you're saying that your code doesn't
> >> work, or asking for general advice, or what? I'm not in a
> >> position to have my machine join a domain or workgroup, but
> >> you seem to have got most things in place already. The only
> >> thing I would expect to have to change is this last line:
>
> >>>    import wmi
> >>>    c = wmi.WMI()
> >>>    d = c.Win32_ComputerSystem
> >>>    d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
> >> because the d is only a WMI *class*, not a WMI *instance*,
> >> so doesn't refer as it should to your computer system but
> >> to the class of computer systems. Try something like this (untested):
>
> >> 
> >> import wmi
>
> >> c = wmi.WMI ()
> >> for d in c.Win32_ComputerSystem ():
> >>   d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
>
> >> 
>
> >> TJG
> > thanks but it doesn't work
> > I've got this errors
>
> > Traceback (most recent call last):
> >  File "integrdom.py", line 51, in 
> >    main()
> >  File "integrdom.py", line 13, in main
> >    joindom()
> >  File "integrdom.py", line 44, in joindom
> >    d.JoinDomainOrWorkGroup(None, 3, "domcd", "adminLocal", r"admin
> > \domcd")
> >  File "c:\Python25\Lib\site-packages\wmi.py", line 493, in __getattr__
> >    handle_com_error (error_info)
> >  File "c:\Python25\Lib\site-packages\wmi.py", line 189, in
> > handle_com_error
> >    raise x_wmi, "\n".join (exception_string)
> > wmi.x_wmi
>
> Do you not get *anything* after than wmi.x_wmi? Not even
> a messy exception string?
>
> TJG

no pessy string

something strange:

import wmi
c = wmi.WMI()
os = c.Win32_ComputerSystem
for method_name in os.methods:
  method = getattr(os, method_name)
  print method

it doesn't give the same parameter order for JoinDomainOrWorkGroup
than MSDN doc
--
http://mail.python.org/mailman/listinfo/python-list


Re: join a samba domain

2008-12-22 Thread Toff
On 22 déc, 18:59, Jens Henrik Leonhard Jensen
 wrote:
> Toff wrote:
> >    d = c.Win32_ComputerSystem
> >    d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
>
> Shouldn't r"admin\\mydom" be "admin\\mydom" or r"admin\mydom".
> Or maybe just "admin"
>
> /Jens Henrik

you are right but i've got the same error.
--
http://mail.python.org/mailman/listinfo/python-list


Re: join a samba domain

2008-12-23 Thread Toff
On 22 déc, 19:37, Toff  wrote:
> On 22 déc, 18:59, Jens Henrik Leonhard Jensen
>
>  wrote:
> > Toff wrote:
> > >    d = c.Win32_ComputerSystem
> > >    d.JoinDomainOrWorkGroup(None, 3, "mydom", "mydompw", r"admin\\mydom")
>
> > Shouldn't r"admin\\mydom" be "admin\\mydom" or r"admin\mydom".
> > Or maybe just "admin"
>
> > /Jens Henrik
>
> you are right but i've got the same error.

the more i look at my script the more i think it s a BUG.

#ALL works great
import wmi
c = wmi.WMI()
for computer in c.Win32_ComputerSystem():
if computer.PartOfDomain:
print computer.Domain #DOMCD
print computer.SystemStartupOptions # (u'"Microsoft 
Windows XP
Professionnel" /noexecute=optin /fastdetect',)

#error message
computer.JoinDomainOrWorkGroup('DOMCD', 'adminLocal', 
'admin\
\DOMCD',None,3  )


##
DOMCD
(u'"Microsoft Windows XP Professionnel" /noexecute=optin /
fastdetect',)
Traceback (most recent call last):
  File "integrdom.py", line 51, in 
main()
  File "integrdom.py", line 13, in main
joindom()
  File "integrdom.py", line 47, in joindom
computer.JoinDomainOrWorkGroup('DOMCD', 'adminLocal', 'admin\
\DOMCD',None,3
 )
  File "c:\Python25\Lib\site-packages\wmi.py", line 493, in
__getattr__
handle_com_error (error_info)
  File "c:\Python25\Lib\site-packages\wmi.py", line 189, in
handle_com_error
raise x_wmi, "\n".join (exception_string)
wmi.x_wmi
--
http://mail.python.org/mailman/listinfo/python-list


Re: join a samba domain

2008-12-23 Thread Toff
Or maybe could I try with
LoadLibrary("netapi32.dll");
and the netjoindomain function ?

but it doesn't look very easy 
--
http://mail.python.org/mailman/listinfo/python-list


win32 wins settings

2009-04-14 Thread Toff
hello
I don't understand why this doesn't woks.


def setwins(self):
from win32com.client import GetObject
objWMIService = GetObject("winmgmts:
{impersonationLevel=impersonate}!.\\root\\cimv2")
colNicConfigs = objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
for nic in colNicConfigs:
print nic.Description
nic.SetWINSServer('','')

it looks good
http://msdn.microsoft.com/en-us/library/aa393624(VS.85).aspx

someone got helps ?

thanks
--
http://mail.python.org/mailman/listinfo/python-list


help to convert c++ fonction in python

2009-10-17 Thread Toff
hello

I'm trying to convert  2 c++ functions  in python


they come from wpkg client
https://wpkg.svn.sourceforge.net/svnroot/wpkg/wpkg-client/Sources/Components/XmlSettings.cpp

they are
CString CXmlSettings::Crypt(CString str)
CString CXmlSettings::Decrypt(CString str)



CAn someone help me?
i d'ont know much about c++

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help to convert c++ fonction in python

2009-10-17 Thread Toff
On 18 oct, 02:13, geremy condra  wrote:
> On Sat, Oct 17, 2009 at 7:57 PM, David Robinow  wrote:
> > On Sat, Oct 17, 2009 at 7:48 PM, geremy condra  wrote:
> >> For the love of baby kittens, please, please, please tell me that
> >> you do not believe this securely encrypts your data.
> >  Yeah, I think it's pretty good.
> > Can you do better?
>
> Trivially. Use AES, 3DES, any standard cryptosystem- there are
> literally dozens of excellent, well-studied implementations in
> both C++ and Python, and hardware implementations on many
> processors.
>
> The cipher listed will fall in a single round of chosen plaintext
> attacks or chosen ciphertext attacks, and with a keylength of
> 40 bytes against a message length of 768 will give me roughly
> 19 windows on a single encryption. Frequency analysis is
> therefore going to be extremely profitable, not to mention
> trivially easy.
>
> Geremy Condra



Thanks a lot Tim !



@Geremy :
this is not a methode to encrypt data
it is more a methode to encode /decode strings

for exemple to store passwords that need  to be used by others
programs
yes it 's insecure
but there is no secure way to store password that 's need to be
retrieve


PS : sorry for my english
-- 
http://mail.python.org/mailman/listinfo/python-list


lmlx & & caracter

2009-10-27 Thread Toff
hello

i can't parse a file with lxml



  
 
 
  http://download.mozilla.org/?
product=firefox-3.5&os=win&lang=fr"  />
  
  
=

i know that & is a special caracter in xml

but how to parse the file

here is what i do :
filename = "file.xml"
xml = etree.parse(filename)
xml = ET.parse(filename)
for group in xml.getiterator('package'):
print group.get('id')


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lmlx & & caracter

2009-10-27 Thread Toff
sorry for my english
thanks again for your answer ;)


i did that 

o = open("output.txt","w")
data = open(filename).read()
o.write( re.sub('&(?!amp;|quot;|nbsp;|gt;|lt;|laquo;|
raquo;|copy;|reg;|bul;|rsquo;)', '&', data) )
o.close()
shutil.move
("output.txt",filename)
xml = etree.parse(filename)
xml = ET.parse(filename)

it's dirty but works



On 27 oct, 09:36, Stefan Behnel  wrote:
> Toff, 27.10.2009 09:15:
>
>
>
> > On 27 oct, 09:03, Christian Heimes  wrote:
> >> Toff wrote:
> >>> hello
> >>> i can't parse a file with lxml
> >>> 
> >>>   
> >>>  
> >>>  
> >>>   http://download.mozilla.org/?
> >>> product=firefox-3.5&os=win&lang=fr"  />
> >>>   
> >>>   
> >>> =
> >>> i know that & is a special caracter in xml
> >> Because & has a special meaning in XML you have to quote a literal & as
> >> &
>
> > but does my download url still allways works with & replace by $amp;
>
> In case you want to know if the URL keeps working if you replace '&' by
> '&' in your XML file, then the answer is that it will actually /start/
> working that way, because it will not work the way you show above. An XML
> parser will return the URL as expected.
>
> Note that it's also best to use an XML toolkit to actually generate XML, in
> case you wrote the above file programmatically.
>
> Stefan

-- 
http://mail.python.org/mailman/listinfo/python-list