| 1 | /* Samba REXX Function Library for RPC calls */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH.
|
|---|
| 5 |
|
|---|
| 6 | This program is free software: you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | /* Currently implemented functions: */
|
|---|
| 22 | /* _rpcenumdomgroups(server,username,password) */
|
|---|
| 23 | /* _rpcenumdomusers(server,username,password) */
|
|---|
| 24 | /* _rpcenumprinters(server,username,password) */
|
|---|
| 25 | /* _rpcnetshareenum(server,username,password) */
|
|---|
| 26 | /* _rpcnetsharegetinfo(server,username,password,share) */
|
|---|
| 27 | /* _rpcquerygroupmem(server,username,password,grouprid) */
|
|---|
| 28 | /* _rpcqueryuser(server,username,password,userrid) */
|
|---|
| 29 | /* _rpcsrvinfo(server,username,password) */
|
|---|
| 30 |
|
|---|
| 31 | /*:VRX _rpcenumdomgroups
|
|---|
| 32 | */
|
|---|
| 33 | _rpcenumdomgroups: procedure expose rpc. samba. options. debuglevel
|
|---|
| 34 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() started"
|
|---|
| 35 | server = arg(1)
|
|---|
| 36 | username = arg(2)
|
|---|
| 37 | password = arg(3)
|
|---|
| 38 |
|
|---|
| 39 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 40 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups" 'debuglevel' '
|
|---|
| 41 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups" 'debuglevel' >'samba.!msg
|
|---|
| 42 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 43 |
|
|---|
| 44 | rpc.enumdomgroups. = ""
|
|---|
| 45 |
|
|---|
| 46 | Failure = 0
|
|---|
| 47 |
|
|---|
| 48 | count = 0
|
|---|
| 49 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 50 | do until lines(samba.!msg) = 0
|
|---|
| 51 | rpcline = linein(samba.!msg)
|
|---|
| 52 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 53 |
|
|---|
| 54 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 55 | Failure = 1
|
|---|
| 56 | leave
|
|---|
| 57 | end
|
|---|
| 58 | parse var rpcline 'group:['tuser'] rid:['trid']'
|
|---|
| 59 |
|
|---|
| 60 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 61 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 62 | count = count + 1
|
|---|
| 63 |
|
|---|
| 64 | dyn = 'rpc.enumdomgroups.'count'.GROUP = "'Tuser'"'
|
|---|
| 65 | say " "dyn
|
|---|
| 66 | interpret dyn
|
|---|
| 67 |
|
|---|
| 68 | dyn = 'rpc.enumdomgroups.'count'.RID = "'Trid'"'
|
|---|
| 69 | say " "dyn
|
|---|
| 70 | interpret dyn
|
|---|
| 71 |
|
|---|
| 72 | end
|
|---|
| 73 | SIGNAL OFF SYNTAX
|
|---|
| 74 | ok = stream(samba.!msg,'c','close')
|
|---|
| 75 | ok = SysFileDelete(samba.!msg)
|
|---|
| 76 | rpc.enumdomgroups.0 = count
|
|---|
| 77 |
|
|---|
| 78 | if Failure = 0 then do
|
|---|
| 79 | retval = 1
|
|---|
| 80 | rpc.enumdomgroups.LOGONSTATUS="OK"
|
|---|
| 81 | end
|
|---|
| 82 | else do
|
|---|
| 83 | retval = 0
|
|---|
| 84 | rpc.enumdomgroups.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 85 | end
|
|---|
| 86 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() done, "retval" "rpc.enumdomgroups.LOGONSTATUS
|
|---|
| 87 | return retval
|
|---|
| 88 |
|
|---|
| 89 | /*:VRX _rpcenumdomusers
|
|---|
| 90 | */
|
|---|
| 91 | _rpcenumdomusers: procedure expose rpc. samba. options. debuglevel
|
|---|
| 92 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() started"
|
|---|
| 93 | server = arg(1)
|
|---|
| 94 | username = arg(2)
|
|---|
| 95 | password = arg(3)
|
|---|
| 96 |
|
|---|
| 97 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 98 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers" 'debuglevel' '
|
|---|
| 99 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers" 'debuglevel' >'samba.!msg
|
|---|
| 100 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 101 |
|
|---|
| 102 | rpc.enumdomusers. = ""
|
|---|
| 103 |
|
|---|
| 104 | Failure = 0
|
|---|
| 105 |
|
|---|
| 106 | count = 0
|
|---|
| 107 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 108 | do until lines(samba.!msg) = 0
|
|---|
| 109 | rpcline = linein(samba.!msg)
|
|---|
| 110 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 111 |
|
|---|
| 112 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 113 | Failure = 1
|
|---|
| 114 | leave
|
|---|
| 115 | end
|
|---|
| 116 | parse var rpcline 'user:['tuser'] rid:['trid']'
|
|---|
| 117 |
|
|---|
| 118 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 119 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 120 | count = count + 1
|
|---|
| 121 |
|
|---|
| 122 | dyn = 'rpc.enumdomusers.'count'.USER = "'Tuser'"'
|
|---|
| 123 | say " "dyn
|
|---|
| 124 | interpret dyn
|
|---|
| 125 |
|
|---|
| 126 | dyn = 'rpc.enumdomusers.'count'.RID = "'Trid'"'
|
|---|
| 127 | say " "dyn
|
|---|
| 128 | interpret dyn
|
|---|
| 129 |
|
|---|
| 130 | end
|
|---|
| 131 | SIGNAL OFF SYNTAX
|
|---|
| 132 | ok = stream(samba.!msg,'c','close')
|
|---|
| 133 | ok = SysFileDelete(samba.!msg)
|
|---|
| 134 | rpc.enumdomusers.0 = count
|
|---|
| 135 |
|
|---|
| 136 | if Failure = 0 then do
|
|---|
| 137 | retval = 1
|
|---|
| 138 | rpc.enumdomusers.LOGONSTATUS="OK"
|
|---|
| 139 | end
|
|---|
| 140 | else do
|
|---|
| 141 | retval = 0
|
|---|
| 142 | rpc.enumdomusers.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 143 | end
|
|---|
| 144 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() done, "retval" "rpc.enumdomusers.LOGONSTATUS
|
|---|
| 145 | return retval
|
|---|
| 146 |
|
|---|
| 147 | /*:VRX _rpcenumprinters
|
|---|
| 148 | */
|
|---|
| 149 | _rpcenumprinters: procedure expose rpc. samba. options. debuglevel
|
|---|
| 150 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() started"
|
|---|
| 151 | server = arg(1)
|
|---|
| 152 | username = arg(2)
|
|---|
| 153 | password = arg(3)
|
|---|
| 154 |
|
|---|
| 155 | usercred = '--user='username'%'password
|
|---|
| 156 |
|
|---|
| 157 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 158 | say ' 'samba.!rpcclientexe' 'server' 'usercred' --command="enumprinters" 'debuglevel' '
|
|---|
| 159 | address cmd samba.!rpcclientexe' 'server' 'usercred' --command="enumprinters" 'debuglevel' >'samba.!msg
|
|---|
| 160 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 161 |
|
|---|
| 162 | rpc.enumprinters. = ""
|
|---|
| 163 |
|
|---|
| 164 | Failure = 0
|
|---|
| 165 |
|
|---|
| 166 | count = 0
|
|---|
| 167 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 168 | do until lines(samba.!msg) = 0
|
|---|
| 169 | rpcline = linein(samba.!msg)
|
|---|
| 170 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 171 |
|
|---|
| 172 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 173 | Failure = 1
|
|---|
| 174 | leave
|
|---|
| 175 | end
|
|---|
| 176 | parse var rpcline token ':[' tvalue']' .
|
|---|
| 177 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 178 | if Token = "FLAGS" then count = count + 1
|
|---|
| 179 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 180 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
|---|
| 181 | dyn = 'rpc.enumprinters.'count'.'Token' = "'Tvalue'"'
|
|---|
| 182 | say " "dyn
|
|---|
| 183 | interpret dyn
|
|---|
| 184 | end
|
|---|
| 185 | end
|
|---|
| 186 | SIGNAL OFF SYNTAX
|
|---|
| 187 | ok = stream(samba.!msg,'c','close')
|
|---|
| 188 | ok = SysFileDelete(samba.!msg)
|
|---|
| 189 | rpc.enumprinters.0 = count
|
|---|
| 190 |
|
|---|
| 191 | if Failure = 0 then do
|
|---|
| 192 | retval = 1
|
|---|
| 193 | rpc.enumprinters.LOGONSTATUS="OK"
|
|---|
| 194 | end
|
|---|
| 195 | else do
|
|---|
| 196 | retval = 0
|
|---|
| 197 | rpc.enumprinters.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 198 | end
|
|---|
| 199 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() done, "retval" "rpc.enumprinters.LOGONSTATUS
|
|---|
| 200 | return retval
|
|---|
| 201 | /*:VRX _rpcnetshareenum
|
|---|
| 202 | */
|
|---|
| 203 | _rpcnetshareenum: procedure expose rpc. samba. options. debuglevel
|
|---|
| 204 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() started"
|
|---|
| 205 | server = arg(1)
|
|---|
| 206 | username = arg(2)
|
|---|
| 207 | password = arg(3)
|
|---|
| 208 |
|
|---|
| 209 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 210 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum" 'debuglevel' '
|
|---|
| 211 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum" 'debuglevel' >'samba.!msg
|
|---|
| 212 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 213 |
|
|---|
| 214 | rpc.netshareenum. = ""
|
|---|
| 215 |
|
|---|
| 216 | Failure = 0
|
|---|
| 217 |
|
|---|
| 218 | count = 0
|
|---|
| 219 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 220 | do until lines(samba.!msg) = 0
|
|---|
| 221 | rpcline = linein(samba.!msg)
|
|---|
| 222 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 223 |
|
|---|
| 224 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 225 | Failure = 1
|
|---|
| 226 | leave
|
|---|
| 227 | end
|
|---|
| 228 | parse var rpcline token ':' tvalue
|
|---|
| 229 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 230 | if Token = "NETNAME" then count = count + 1
|
|---|
| 231 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 232 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
|---|
| 233 | dyn = 'rpc.netshareenum.'count'.'Token' = "'Tvalue'"'
|
|---|
| 234 | say " "dyn
|
|---|
| 235 | interpret dyn
|
|---|
| 236 | end
|
|---|
| 237 | end
|
|---|
| 238 | SIGNAL OFF SYNTAX
|
|---|
| 239 | ok = stream(samba.!msg,'c','close')
|
|---|
| 240 | ok = SysFileDelete(samba.!msg)
|
|---|
| 241 | rpc.netshareenum.0 = count
|
|---|
| 242 |
|
|---|
| 243 | if Failure = 0 then do
|
|---|
| 244 | retval = 1
|
|---|
| 245 | rpc.netshareenum.LOGONSTATUS="OK"
|
|---|
| 246 | end
|
|---|
| 247 | else do
|
|---|
| 248 | retval = 0
|
|---|
| 249 | rpc.netshareenum.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 250 | end
|
|---|
| 251 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() done, "retval" "rpc.netshareenum.LOGONSTATUS
|
|---|
| 252 | return retval
|
|---|
| 253 |
|
|---|
| 254 | /*:VRX _rpcnetsharegetinfo
|
|---|
| 255 | */
|
|---|
| 256 | _rpcnetsharegetinfo: procedure expose rpc. samba. options. debuglevel
|
|---|
| 257 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() started"
|
|---|
| 258 | server = arg(1)
|
|---|
| 259 | username = arg(2)
|
|---|
| 260 | password = arg(3)
|
|---|
| 261 | share = arg(4)
|
|---|
| 262 |
|
|---|
| 263 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 264 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'" 'debuglevel' '
|
|---|
| 265 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'" 'debuglevel' >'samba.!msg
|
|---|
| 266 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 267 |
|
|---|
| 268 | rpc.netsharegetinfo. = ""
|
|---|
| 269 |
|
|---|
| 270 | Failure = 0
|
|---|
| 271 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 272 | do until lines(samba.!msg) = 0
|
|---|
| 273 | rpcline = linein(samba.!msg)
|
|---|
| 274 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 275 |
|
|---|
| 276 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 277 | Failure = 1
|
|---|
| 278 | leave
|
|---|
| 279 | end
|
|---|
| 280 | parse var rpcline token ':' tvalue
|
|---|
| 281 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 282 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 283 | if pos('ACL',Token) = 0 & pos('ACE',Token) = 0 & pos('---',Token) = 0 & Token <> "" then do
|
|---|
| 284 |
|
|---|
| 285 | if Token = "TYPE" & left(Tvalue,2) = "0x" & length(Tvalue) = 3 then Token = "SHARETYPE"
|
|---|
| 286 | if Token = "TYPE" & pos("SEC",Tvalue) > 1 then Token = "SECTYPE"
|
|---|
| 287 |
|
|---|
| 288 | dyn = 'rpc.netsharegetinfo.'Token' = "'Tvalue'"'
|
|---|
| 289 | say " "dyn
|
|---|
| 290 | interpret dyn
|
|---|
| 291 | end
|
|---|
| 292 | end
|
|---|
| 293 | SIGNAL OFF SYNTAX
|
|---|
| 294 | ok = stream(samba.!msg,'c','close')
|
|---|
| 295 | ok = SysFileDelete(samba.!msg)
|
|---|
| 296 |
|
|---|
| 297 | if Failure = 0 then do
|
|---|
| 298 | retval = '1'
|
|---|
| 299 | rpc.netsharegetinfo.LOGONSTATUS="OK"
|
|---|
| 300 | end
|
|---|
| 301 | else do
|
|---|
| 302 | retval = '0 '
|
|---|
| 303 | rpc.netsharegetinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 304 | end
|
|---|
| 305 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() done, "retval" "rpc.netsharegetinfo.LOGONSTATUS
|
|---|
| 306 | return retval
|
|---|
| 307 |
|
|---|
| 308 | /*:VRX _rpcquerygroupmem
|
|---|
| 309 | */
|
|---|
| 310 | _rpcquerygroupmem: procedure expose rpc. samba. options. debuglevel
|
|---|
| 311 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() started"
|
|---|
| 312 | server = arg(1)
|
|---|
| 313 | username = arg(2)
|
|---|
| 314 | password = arg(3)
|
|---|
| 315 | grouprid = arg(4)
|
|---|
| 316 |
|
|---|
| 317 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'" 'debuglevel' '
|
|---|
| 318 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'" 'debuglevel' >'samba.!msg
|
|---|
| 319 |
|
|---|
| 320 | rpc.querygroupmem. = ""
|
|---|
| 321 |
|
|---|
| 322 | Failure = 0
|
|---|
| 323 |
|
|---|
| 324 | count = 0
|
|---|
| 325 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 326 | do until lines(samba.!msg) = 0
|
|---|
| 327 | rpcline = linein(samba.!msg)
|
|---|
| 328 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 329 |
|
|---|
| 330 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 331 | Failure = 1
|
|---|
| 332 | leave
|
|---|
| 333 | end
|
|---|
| 334 | parse var rpcline 'rid:['trid'] attr:['tattr']'
|
|---|
| 335 |
|
|---|
| 336 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 337 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 338 | count = count + 1
|
|---|
| 339 |
|
|---|
| 340 | dyn = 'rpc.querygroupmem.'count'.RID = "'Trid'"'
|
|---|
| 341 | say " "dyn
|
|---|
| 342 | interpret dyn
|
|---|
| 343 |
|
|---|
| 344 | dyn = 'rpc.querygroupmem.'count'.ATTR = "'Tattr'"'
|
|---|
| 345 | say " "dyn
|
|---|
| 346 | interpret dyn
|
|---|
| 347 |
|
|---|
| 348 | end
|
|---|
| 349 | SIGNAL OFF SYNTAX
|
|---|
| 350 | ok = stream(samba.!msg,'c','close')
|
|---|
| 351 | ok = SysFileDelete(samba.!msg)
|
|---|
| 352 | rpc.querygroupmem.0 = count
|
|---|
| 353 |
|
|---|
| 354 | if Failure = 0 then do
|
|---|
| 355 | retval = 1
|
|---|
| 356 | rpc.querygroupmem.LOGONSTATUS="OK"
|
|---|
| 357 | end
|
|---|
| 358 | else do
|
|---|
| 359 | retval = 0
|
|---|
| 360 | rpc.querygroupmem.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 361 | end
|
|---|
| 362 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() done, "retval" "rpc.querygroupmem.LOGONSTATUS
|
|---|
| 363 | return retval
|
|---|
| 364 | /*:VRX _rpcqueryuser
|
|---|
| 365 | */
|
|---|
| 366 | _rpcqueryuser: procedure expose rpc. samba. options. debuglevel
|
|---|
| 367 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() started"
|
|---|
| 368 | server = arg(1)
|
|---|
| 369 | username = arg(2)
|
|---|
| 370 | password = arg(3)
|
|---|
| 371 | userrid = arg(4)
|
|---|
| 372 |
|
|---|
| 373 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 374 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'" 'debuglevel' '
|
|---|
| 375 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'" 'debuglevel' >'samba.!msg
|
|---|
| 376 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 377 |
|
|---|
| 378 | rpc.queryuser. = ""
|
|---|
| 379 |
|
|---|
| 380 | Failure = 0
|
|---|
| 381 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 382 | do until lines(samba.!msg) = 0
|
|---|
| 383 | rpcline = linein(samba.!msg)
|
|---|
| 384 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 385 |
|
|---|
| 386 | if pos("NT_STATUS", rpcline) > 0 then do
|
|---|
| 387 | Failure = 1
|
|---|
| 388 | leave
|
|---|
| 389 | end
|
|---|
| 390 | if pos("TDB(", translate(rpcline)) > 0 then do
|
|---|
| 391 | Failure = 1
|
|---|
| 392 | /* provide a fake NT_STATUS */
|
|---|
| 393 | rpcline = 'NT_STATUS_TDBERROR 'rpcline
|
|---|
| 394 | leave
|
|---|
| 395 | end
|
|---|
| 396 |
|
|---|
| 397 | parse var rpcline token ':' tvalue
|
|---|
| 398 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 399 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 400 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
|---|
| 401 | dyn = 'rpc.queryuser.'Token' = "'Tvalue'"'
|
|---|
| 402 | say " "dyn
|
|---|
| 403 | interpret dyn
|
|---|
| 404 | end
|
|---|
| 405 | end
|
|---|
| 406 | SIGNAL OFF SYNTAX
|
|---|
| 407 | ok = stream(samba.!msg,'c','close')
|
|---|
| 408 | ok = SysFileDelete(samba.!msg)
|
|---|
| 409 |
|
|---|
| 410 | if Failure = 0 then do
|
|---|
| 411 | retval = 1
|
|---|
| 412 | rpc.queryuser.LOGONSTATUS="OK"
|
|---|
| 413 | end
|
|---|
| 414 | else do
|
|---|
| 415 | retval = '0 '
|
|---|
| 416 | rpc.queryuser.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 417 | end
|
|---|
| 418 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() done, "retval" "rpc.queryuser.LOGONSTATUS
|
|---|
| 419 | return retval
|
|---|
| 420 | /*:VRX _rpcsrvinfo
|
|---|
| 421 | */
|
|---|
| 422 | _rpcsrvinfo: procedure expose rpc. samba. options. debuglevel tempdir
|
|---|
| 423 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() started"
|
|---|
| 424 | server = arg(1)
|
|---|
| 425 | username = arg(2)
|
|---|
| 426 | password = arg(3)
|
|---|
| 427 |
|
|---|
| 428 | /* Initialize temporary files */
|
|---|
| 429 | rpcinfo.!msg = SysTempFileName(TempDir||"rpcinfo_msg.???")
|
|---|
| 430 | rpcinfo.!err = SysTempFileName(TempDir||"rpcinfo_err.???")
|
|---|
| 431 | ok = stream(rpcinfo.!msg,'c','close')
|
|---|
| 432 | ok = stream(rpcinfo.!err,'c','close')
|
|---|
| 433 | ok = SysFileDelete(rpcinfo.!msg)
|
|---|
| 434 | ok = SysFileDelete(rpcinfo.!err)
|
|---|
| 435 |
|
|---|
| 436 | usercred = '--user='username'%'password
|
|---|
| 437 | if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
|
|---|
| 438 |
|
|---|
| 439 | call VRSet VRWindow(), 'Pointer', 'Wait'
|
|---|
| 440 | say ' 'samba.!rpcclientexe' 'server' 'usercred' --command="srvinfo" 'debuglevel' 2>'rpcinfo.!err' 1>'rpcinfo.!msg
|
|---|
| 441 | address cmd samba.!rpcclientexe' 'server' 'usercred' --command="srvinfo" 'debuglevel' 2>'rpcinfo.!err' 1>'rpcinfo.!msg
|
|---|
| 442 | call VRSet VRWindow(), 'Pointer', '<default>'
|
|---|
| 443 |
|
|---|
| 444 | rpc.srvinfo. = ""
|
|---|
| 445 |
|
|---|
| 446 | Failure = 0
|
|---|
| 447 | do while lines(rpcinfo.!err) > 0
|
|---|
| 448 | rpcline = linein(rpcinfo.!err)
|
|---|
| 449 | IF options.!debug == 1 THEN say " "rpcinfo.!err': "'rpcline'"'
|
|---|
| 450 | if pos("UNSUCCESSFUL", translate(rpcline)) > 0 | pos("CANNOT CONNECT", translate(rpcline)) > 0 then do
|
|---|
| 451 | ok = stream(rpcinfo.!msg,'c','close')
|
|---|
| 452 | ok = stream(rpcinfo.!err,'c','close')
|
|---|
| 453 | ok = SysFileDelete(rpcinfo.!msg)
|
|---|
| 454 | ok = SysFileDelete(rpcinfo.!err)
|
|---|
| 455 | Failure = 1
|
|---|
| 456 | retval = 0
|
|---|
| 457 | rpc.srvinfo. = ""
|
|---|
| 458 | rpc.srvinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 459 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() aborted, "retval
|
|---|
| 460 | return retval
|
|---|
| 461 | end
|
|---|
| 462 | end
|
|---|
| 463 |
|
|---|
| 464 | SIGNAL ON SYNTAX NAME RPCERROR
|
|---|
| 465 | do until lines(rpcinfo.!msg) = 0
|
|---|
| 466 | rpcline = linein(rpcinfo.!msg)
|
|---|
| 467 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
|---|
| 468 | if pos("TDB(",translate(rpcline)) <> 0 then iterate
|
|---|
| 469 |
|
|---|
| 470 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
|---|
| 471 | Failure = 1
|
|---|
| 472 | leave
|
|---|
| 473 | end
|
|---|
| 474 | if pos(':',rpcline) <> 0 then do
|
|---|
| 475 | parse var rpcline token ':' tvalue
|
|---|
| 476 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
|---|
| 477 | tvalue= strip(strip(tvalue,'L','09'x))
|
|---|
| 478 | dyn = 'rpc.srvinfo.'Token' = "'Tvalue'"'
|
|---|
| 479 | say " "dyn
|
|---|
| 480 | interpret dyn
|
|---|
| 481 | end
|
|---|
| 482 | else do
|
|---|
| 483 | parse var rpcline '09'x rpc.srvinfo.NETBIOSNAME' 'rpc.srvinfo.SERVERSTRING
|
|---|
| 484 | rpc.srvinfo.SERVERSTRING = strip(rpc.srvinfo.SERVERSTRING)
|
|---|
| 485 | say ' rpc.srvinfo.NETBIOSNAME = "'rpc.srvinfo.NETBIOSNAME'"'
|
|---|
| 486 | say ' rpc.srvinfo.SERVERSTRING = "'rpc.srvinfo.SERVERSTRING'"'
|
|---|
| 487 | rpc.srvinfo.CAPABILITIES = ""
|
|---|
| 488 | do I = 1 to words(rpc.srvinfo.SERVERSTRING)
|
|---|
| 489 | /* say "Word "I":"word(rpc.srvinfo.SERVERSTRING,I) */
|
|---|
| 490 | if length(word(rpc.srvinfo.SERVERSTRING,I)) >=4 then leave
|
|---|
| 491 | if length(word(rpc.srvinfo.SERVERSTRING,I)) = 2 | length(word(rpc.srvinfo.SERVERSTRING,I)) = 3 then do
|
|---|
| 492 | rpc.srvinfo.CAPABILITIES = rpc.srvinfo.CAPABILITIES||word(rpc.srvinfo.SERVERSTRING,I)||' '
|
|---|
| 493 | end
|
|---|
| 494 | end
|
|---|
| 495 | if rpc.srvinfo.CAPABILITIES <> "" then do
|
|---|
| 496 | rpc.srvinfo.SERVERSTRING = strip(substr(rpc.srvinfo.SERVERSTRING,length(rpc.srvinfo.CAPABILITIES),))
|
|---|
| 497 | rpc.srvinfo.CAPABILITIES = strip(rpc.srvinfo.CAPABILITIES)
|
|---|
| 498 | end
|
|---|
| 499 | say ' rpc.srvinfo.CAPABILITIES = "'rpc.srvinfo.CAPABILITIES'"'
|
|---|
| 500 | say ' rpc.srvinfo.SERVERSTRING = "'rpc.srvinfo.SERVERSTRING'"'
|
|---|
| 501 | end
|
|---|
| 502 | end
|
|---|
| 503 | SIGNAL OFF SYNTAX
|
|---|
| 504 |
|
|---|
| 505 | ok = stream(rpcinfo.!msg,'c','close')
|
|---|
| 506 | ok = stream(rpcinfo.!err,'c','close')
|
|---|
| 507 | ok = SysFileDelete(rpcinfo.!msg)
|
|---|
| 508 | ok = SysFileDelete(rpcinfo.!err)
|
|---|
| 509 |
|
|---|
| 510 | if Failure = 0 then do
|
|---|
| 511 | retval = 1
|
|---|
| 512 | rpc.srvinfo.LOGONSTATUS="OK"
|
|---|
| 513 | end
|
|---|
| 514 | else do
|
|---|
| 515 | retval = 0
|
|---|
| 516 | rpc.srvinfo. = ""
|
|---|
| 517 | rpc.srvinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
|---|
| 518 | end
|
|---|
| 519 | say ' rpc.srvinfo.LOGONSTATUS = "'rpc.srvinfo.LOGONSTATUS'"'
|
|---|
| 520 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() done, "retval
|
|---|
| 521 | return retval
|
|---|
| 522 |
|
|---|
| 523 | RPCERROR:
|
|---|
| 524 | ok = stream(rpcinfo.!msg,'c','close')
|
|---|
| 525 | ok = stream(rpcinfo.!err,'c','close')
|
|---|
| 526 | ok = SysFileDelete(rpcinfo.!msg)
|
|---|
| 527 | ok = SysFileDelete(rpcinfo.!err)
|
|---|
| 528 |
|
|---|
| 529 | say " rpc parsing error in line "sigl": "strip(sourceline(sigl))
|
|---|
| 530 | retval = -1
|
|---|
| 531 | IF options.!debug == 1 THEN SAY time()" _rpclibrary aborted, "retval
|
|---|
| 532 | return retval
|
|---|