/** * Get a handle to a service * * @param url * @param tc * context to use * @return a DCERPC handle for the given url * @throws MalformedURLException * @throws DcerpcException */ public static DcerpcHandle getHandle ( String url, CIFSContext tc ) throws MalformedURLException, DcerpcException { return getHandle(url, tc, false); }
/** * Get a handle to a service * * @param url * @param tc * context to use * @return a DCERPC handle for the given url * @throws MalformedURLException * @throws DcerpcException */ public static DcerpcHandle getHandle ( String url, CIFSContext tc ) throws MalformedURLException, DcerpcException { return getHandle(url, tc, false); }
void resolveSids0 ( String authorityServerName, CIFSContext tc, jcifs.SID[] sids ) throws CIFSException { synchronized ( this.sidCache ) { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", tc) ) { String server = authorityServerName; int dot = server.indexOf('.'); if ( dot > 0 && Character.isDigit(server.charAt(0)) == false ) server = server.substring(0, dot); try ( LsaPolicyHandle policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800) ) { resolveSids(handle, policyHandle, sids); } } catch ( IOException e ) { throw new CIFSException("Failed to resolve SIDs", e); } } }
void resolveSids0 ( String authorityServerName, CIFSContext tc, jcifs.SID[] sids ) throws CIFSException { synchronized ( this.sidCache ) { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", tc) ) { String server = authorityServerName; int dot = server.indexOf('.'); if ( dot > 0 && Character.isDigit(server.charAt(0)) == false ) server = server.substring(0, dot); try ( LsaPolicyHandle policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800) ) { resolveSids(handle, policyHandle, sids); } } catch ( IOException e ) { throw new CIFSException("Failed to resolve SIDs", e); } } }
static void resolveSids0(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) throws IOException { DcerpcHandle handle = null; LsaPolicyHandle policyHandle = null; try { handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", auth); String server = authorityServerName; int dot = server.indexOf('.'); if (dot > 0 && Character.isDigit(server.charAt(0)) == false) server = server.substring(0, dot); policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800); SID.resolveSids(handle, policyHandle, sids); } finally { if (handle != null) { if (policyHandle != null) { policyHandle.close(); } handle.close(); } } }
static void resolveSids0(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) throws IOException { DcerpcHandle handle = null; LsaPolicyHandle policyHandle = null; synchronized (sid_cache) { try { handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", auth); String server = authorityServerName; int dot = server.indexOf('.'); if (dot > 0 && Character.isDigit(server.charAt(0)) == false) server = server.substring(0, dot); policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800); SID.resolveSids(handle, policyHandle, sids); } finally { if (handle != null) { if (policyHandle != null) { policyHandle.close(); } handle.close(); } } } }
static void resolveSids0(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) throws IOException { DcerpcHandle handle = null; LsaPolicyHandle policyHandle = null; synchronized (sid_cache) { try { handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", auth); String server = authorityServerName; int dot = server.indexOf('.'); if (dot > 0 && Character.isDigit(server.charAt(0)) == false) server = server.substring(0, dot); policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800); SID.resolveSids(handle, policyHandle, sids); } finally { if (handle != null) { if (policyHandle != null) { policyHandle.close(); } handle.close(); } } } }
static void resolveSids0(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) throws IOException { DcerpcHandle handle = null; LsaPolicyHandle policyHandle = null; synchronized (sid_cache) { try { handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\lsarpc]", auth); String server = authorityServerName; int dot = server.indexOf('.'); if (dot > 0 && Character.isDigit(server.charAt(0)) == false) server = server.substring(0, dot); policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800); SID.resolveSids(handle, policyHandle, sids); } finally { if (handle != null) { if (policyHandle != null) { policyHandle.close(); } handle.close(); } } } }
static FileEntry[] doMsrpcShareEnum ( CIFSContext ctx, SmbResourceLocator loc, Address address ) throws IOException { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + getRPCTarget(ctx, loc, address) + "[\\PIPE\\srvsvc]", ctx) ) { MsrpcShareEnum rpc = new MsrpcShareEnum(loc.getServer()); handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } return rpc.getEntries(); } }
static FileEntry[] doDfsRootEnum ( CIFSContext ctx, SmbResourceLocator loc, Address address ) throws IOException { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + getRPCTarget(ctx, loc, address) + "[\\PIPE\\netdfs]", ctx) ) { MsrpcDfsRootEnum rpc = new MsrpcDfsRootEnum(loc.getServer()); handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } return rpc.getEntries(); } }
static FileEntry[] doMsrpcShareEnum ( CIFSContext ctx, SmbResourceLocator loc, Address address ) throws IOException { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + getRPCTarget(ctx, loc, address) + "[\\PIPE\\srvsvc]", ctx) ) { MsrpcShareEnum rpc = new MsrpcShareEnum(loc.getServer()); handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } return rpc.getEntries(); } }
static FileEntry[] doDfsRootEnum ( CIFSContext ctx, SmbResourceLocator loc, Address address ) throws IOException { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + getRPCTarget(ctx, loc, address) + "[\\PIPE\\netdfs]", ctx) ) { MsrpcDfsRootEnum rpc = new MsrpcDfsRootEnum(loc.getServer()); handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } return rpc.getEntries(); } }
FileEntry[] doDfsRootEnum() throws IOException { MsrpcDfsRootEnum rpc; DcerpcHandle handle = null; FileEntry[] entries; handle = DcerpcHandle.getHandle("ncacn_np:" + getAddress().getHostAddress() + "[\\PIPE\\netdfs]", auth); try { rpc = new MsrpcDfsRootEnum(getServer()); handle.sendrecv(rpc); if (rpc.retval != 0) throw new SmbException(rpc.retval, true); return rpc.getEntries(); } finally { try { handle.close(); } catch(IOException ioe) { if (log.level >= 4) ioe.printStackTrace(log); } } } FileEntry[] doMsrpcShareEnum() throws IOException {
FileEntry[] doDfsRootEnum() throws IOException { MsrpcDfsRootEnum rpc; DcerpcHandle handle = null; FileEntry[] entries; handle = DcerpcHandle.getHandle("ncacn_np:" + getAddress().getHostAddress() + "[\\PIPE\\netdfs]", auth); try { rpc = new MsrpcDfsRootEnum(getServer()); handle.sendrecv(rpc); if (rpc.retval != 0) throw new SmbException(rpc.retval, true); return rpc.getEntries(); } finally { try { handle.close(); } catch(IOException ioe) { if (log.level >= 4) ioe.printStackTrace(log); } } } FileEntry[] doMsrpcShareEnum() throws IOException {
FileEntry[] doDfsRootEnum() throws IOException { MsrpcDfsRootEnum rpc; DcerpcHandle handle = null; FileEntry[] entries; handle = DcerpcHandle.getHandle("ncacn_np:" + getAddress().getHostAddress() + "[\\PIPE\\netdfs]", auth); try { rpc = new MsrpcDfsRootEnum(getServer()); handle.sendrecv(rpc); if (rpc.retval != 0) throw new SmbException(rpc.retval, true); return rpc.getEntries(); } finally { try { handle.close(); } catch(IOException ioe) { if (log.level >= 4) ioe.printStackTrace(log); } } } FileEntry[] doMsrpcShareEnum() throws IOException {
FileEntry[] doDfsRootEnum() throws IOException { MsrpcDfsRootEnum rpc; DcerpcHandle handle = null; FileEntry[] entries; handle = DcerpcHandle.getHandle("ncacn_np:" + getAddress().getHostAddress() + "[\\PIPE\\netdfs]", auth); try { rpc = new MsrpcDfsRootEnum(getServer()); handle.sendrecv(rpc); if (rpc.retval != 0) throw new SmbException(rpc.retval, true); return rpc.getEntries(); } finally { try { handle.close(); } catch(IOException ioe) { if (log.level >= 4) ioe.printStackTrace(log); } } } FileEntry[] doMsrpcShareEnum() throws IOException {
@Override public ACE[] getShareSecurity ( boolean resolveSids ) throws IOException { try ( SmbTreeHandleInternal th = ensureTreeConnected() ) { String server = this.fileLocator.getServerWithDfs(); ACE[] aces; MsrpcShareGetInfo rpc = new MsrpcShareGetInfo(server, th.getConnectedShare()); try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + server + "[\\PIPE\\srvsvc]", getContext()) ) { handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } aces = rpc.getSecurity(); if ( aces != null ) { processAces(aces, resolveSids); } } return aces; } }
@Override public ACE[] getShareSecurity ( boolean resolveSids ) throws IOException { try ( SmbTreeHandleInternal th = ensureTreeConnected() ) { String server = this.fileLocator.getServerWithDfs(); ACE[] aces; MsrpcShareGetInfo rpc = new MsrpcShareGetInfo(server, th.getConnectedShare()); try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + server + "[\\PIPE\\srvsvc]", getContext()) ) { handle.sendrecv(rpc); if ( rpc.retval != 0 ) { throw new SmbException(rpc.retval, true); } aces = rpc.getSecurity(); if ( aces != null ) { processAces(aces, resolveSids); } } return aces; } }
@Override public SID getServerSid ( CIFSContext tc, String server ) throws CIFSException { lsarpc.LsarDomainInfo info = new lsarpc.LsarDomainInfo(); MsrpcQueryInformationPolicy rpc; synchronized ( this.sidCache ) { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + server + "[\\PIPE\\lsarpc]", tc) ) { // NetApp doesn't like the 'generic' access mask values try ( LsaPolicyHandle policyHandle = new LsaPolicyHandle(handle, null, 0x00000001) ) { rpc = new MsrpcQueryInformationPolicy(policyHandle, (short) lsarpc.POLICY_INFO_ACCOUNT_DOMAIN, info); handle.sendrecv(rpc); if ( rpc.retval != 0 ) throw new SmbException(rpc.retval, false); } return new SID(info.sid, jcifs.SID.SID_TYPE_DOMAIN, ( new UnicodeString(info.name, false) ).toString(), null, false); } catch ( IOException e ) { throw new CIFSException("Failed to get SID from server", e); } } }
@Override public SID getServerSid ( CIFSContext tc, String server ) throws CIFSException { lsarpc.LsarDomainInfo info = new lsarpc.LsarDomainInfo(); MsrpcQueryInformationPolicy rpc; synchronized ( this.sidCache ) { try ( DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + server + "[\\PIPE\\lsarpc]", tc) ) { // NetApp doesn't like the 'generic' access mask values try ( LsaPolicyHandle policyHandle = new LsaPolicyHandle(handle, null, 0x00000001) ) { rpc = new MsrpcQueryInformationPolicy(policyHandle, (short) lsarpc.POLICY_INFO_ACCOUNT_DOMAIN, info); handle.sendrecv(rpc); if ( rpc.retval != 0 ) throw new SmbException(rpc.retval, false); } return new SID(info.sid, jcifs.SID.SID_TYPE_DOMAIN, ( new UnicodeString(info.name, false) ).toString(), null, false); } catch ( IOException e ) { throw new CIFSException("Failed to get SID from server", e); } } }