예제 #1
0
    def NetShareEnumAll(self, data):
        request = srvsvc.SRVSVCNetrShareEnum(data)
        print "NetrShareEnumAll Level: %d" % request['Level']
        shareEnum = srvsvc.SRVSVCNetrShareEnum1_answer()
        shareEnum['Info'] = srvsvc.SRVSVCShareEnumStruct()
        shareEnum['Info']['Level'] = 1
        shareEnum['Info']['Count'] = len(self.__shares)
        shareEnum['Info']['MaxCount'] = len(self.__shares)
        answer = str(shareEnum)
        for i in self.__shares:
            shareInfo = srvsvc.SRVSVCShareInfo1()
            shareInfo['pNetName'] = id(i)
            shareInfo['Type'] = int(self.__shares[i]['share type'])
            shareInfo['pRemark'] = id(i) + 1
            answer += str(shareInfo)

        for i in self.__shares:
            netName = srvsvc.NDRString()
            remark = srvsvc.NDRString()
            netName['sName'] = (i + '\x00').encode('utf-16le')
            remark['sName'] = (self.__shares[i]['comment'] +
                               '\x00').encode('utf-16le')
            answer += str(netName) + str(remark)

        # and the answer
        answer += struct.pack('<LLL', len(self.__shares), 0, 0)
        return answer
예제 #2
0
 def NetrGetShareInfo(self, data):
     request = srvsvc.SRVSVCNetrShareGetInfo(data)
     print "NetrGetShareInfo Level: %d" % request['Level']
     s = request['NetName'].decode('utf-16le')[:-1].upper().strip()
     share = self.__shares[s]
     answer = srvsvc.SRVSVCSwitchpShareInfo2()
     answer['Level'] = 1
     answer['InfoStruct'] = srvsvc.SRVSVCShareInfo1()
     answer['InfoStruct']['pNetName'] = id(share)
     answer['InfoStruct']['Type'] = int(share['share type'])
     answer['InfoStruct']['pRemark'] = id(share) + 1
     answer = str(answer)
     netName = srvsvc.NDRString()
     remark = srvsvc.NDRString()
     netName['sName'] = request['NetName']
     remark['sName'] = (share['comment'] + '\x00').encode('utf-16le')
     answer += str(netName) + str(remark)
     answer += struct.pack('<L', 0)
     return answer