sspiContext.setPrincipalName(targetName); sspiContext.setCredentialsHandle(clientCredentials); sspiContext.setSecurityPackage(securityPackage); sspiContext.initialize(null, null, targetName); } catch (Win32Exception ex) {
clientContext.setPrincipalName(Advapi32Util.getUserName()); clientContext.setCredentialsHandle(credentials.getHandle()); clientContext.setSecurityPackage(securityPackage); clientContext.initialize();
sc.setSecurityPackage(securityPackage); sc.setSecurityContext(phNewServerContext);
clientContext.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); clientContext.setCredentialsHandle(clientCredentials.getHandle()); clientContext.setSecurityPackage(securityPackage); clientContext.initialize(null, null, WindowsAccountImpl.getCurrentUsername());
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }
clientContext.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); clientContext.setCredentialsHandle(clientCredentials.getHandle()); clientContext.setSecurityPackage(securityPackage); clientContext.initialize(null, null, WindowsAccountImpl.getCurrentUsername());
sc.setSecurityPackage(securityPackage); sc.setSecurityContext(phNewServerContext);
sc.setSecurityPackage(securityPackage); sc.setSecurityContext(phNewServerContext);