Python - Ricoh打印机 - 在地址簿中为smb文件夹共享添加密码

时间:2017-05-28 16:40:17

标签: python addressbook printers

我试图编写一个程序,将多个smb文件夹共享添加到我们所有Ricoh Aficio打印机的打印机通讯簿中。我找到了以下模块并添加了以下文件夹字段remoteFolder.path,remoteFolder.accountName和remoteFolder.password。一切都有效,除了密码。我希望有人有这些打印机的经验,可以协助我最后的绊脚石。

提前致谢。

XML

add_user_xml = """\
<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <m:putObjects xmlns:m="http://www.ricoh.co.jp/xmlns/soap/rdh/udirectory">
   <sessionId>{sessionId}</sessionId>
   <objectClass>entry</objectClass>
   <parentObjectId></parentObjectId>
   <propListList xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:itt="http://www.ricoh.co.jp/xmlns/schema/rdh/commontypes" xsi:type="soap-enc:Array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://www.ricoh.co.jp/xmlns/schema/rdh/commontypes" xsi:arrayType="">
    <item xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:itt="http://www.ricoh.co.jp/xmlns/schema/rdh/commontypes" xsi:type="soap-enc:Array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://www.ricoh.co.jp/xmlns/schema/rdh/commontypes" xsi:arrayType="itt:property[9]">
     <item>
      <propName>entryType</propName>
      <propVal>user</propVal>
     </item>
     <item>
      <propName>index</propName>
      <propVal>{index}</propVal>
     </item>
     <item>
      <propName>name</propName>
      <propVal>{name}</propVal>
     </item>
     <item>
      <propName>longName</propName>
      <propVal>{longName}</propVal>
     </item>
     <item>
      <propName>isDestination</propName>
      <propVal>{is_destination}</propVal>
     </item>
     <item>
      <propName>isSender</propName>
      <propVal>{is_sender}</propVal>
     </item>
     <item>
      <propName>mail:</propName>
      <propVal>{mail}</propVal>
     </item>
     <item>
      <propName>mail:address</propName>
      <propVal>{mail_address}</propVal>
     </item>
     <item>
      <propName>remoteFolder:path</propName>
      <propVal>{remoteFolder_path}</propVal>
     </item>
     <item>
      <propName>remoteFolder:accountName</propName>
      <propVal>{remoteFolder_accountName}</propVal>
     </item>     
     <item>
      <propName>remoteFolder:password</propName>
      <propVal>{remoteFolder_password}</propVal>
     </item>     
    </item>
   </propListList>
  </m:putObjects>
 </s:Body>
</s:Envelope>""".strip()

PYTHON

def add_user(self, index=None, name=None, displayName=None, email=False, Folder=None, Fname=None, Fpass=None):
    if not all([name, displayName]):
        return False

    options = dict(
        sessionId=self.stringOut,
        index=self.next_index,
        name=name,
        longName=displayName,
        is_destination='true',
        is_sender='false',
        mail='false', #set to true to expect an email address
        mail_address=email,
        remoteFolder_path=Folder,
        remoteFolder_accountName=Fname,
        remoteFolder_password=Fpass,
    )

    result = self._post_to_copier('putObjects', options, ricoh_xml.add_user_xml)
    if not result['success']:
        self.disconnect()
        raise FatalError

    self.next_index += 1

    return

我的代码

r.add_user(name='username', displayName='user', 
Folder='\\\\IP here\\Folder', 
Fname='username', Fpass='password')

0 个答案:

没有答案