On Mon, 20 Feb 2012 11:53:46 +0000
Tim Golden <m...@timgolden.me.uk> wrote:
> 
> <code>
> import win32net
> 
> def shares (system):
>    share_infos, total, hResume = win32net.NetShareEnum (system, 2, 0)
>    for share_info in share_infos:
>      if share_info['type'] == 0:
>        yield share_info
>    while hResume > 0:
>      share_infos, total, hResume = win32net.NetShareEnum (
>        system, 2, hResume
>      )
>      for share_info in share_infos:
>        if share_info['type'] == 0:
>          yield share_info
> 
> def create_share (system, share_info):
>    win32net.NetShareAdd (system, 2, share_info)
> 
> for share_info in shares ("server1"):
>    create_share ("server2", share_info)
> 
> </code>
> 
> 
> Could you see how far that takes you towards your goal? I'm
> not clear whether you need help specifying the perms on
> the underlying paths, since that would normally be done by
> some kind of backup-restore toolset. But if you need something
> I can certainly advise.


Ok, this is what happens. Your code fails for me in create_share,
because the folders don't exist. So I changed it to this:

def create_share (system, share_info):
  path = share_info['path'].replace(':','$')
  r_dir = r'\\{0}\{1}'.format(system, path)

  if not os.path.exists(r_dir):
    os.makedirs(r_dir)

  win32net.NetShareAdd(system, 2, share_info)

Now that works, and creates the share. But the permission are totally
screwed. Here is an example:

On the existing server we have a share named:
     FINANCE_FSI

Groups that are allowed access to this folder are:
     CCBH_OU_Admins
     CCBH_Finance
     Managed_Care

There are no other groups, no administrator or users. No standard group
name shows in the security tab.

Also, the share permissions and the actual folder have the same
permissions.

Now when recreated on the new server the groups are:
    Administrator
    Creator_Owner
    System
    Users

Not sure if my changes caused the problems with the groups.


-- 

Rod Person  http://www.rodperson.com  rodper...@rodperson.com

'Silence is a fence around wisdom'
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to