Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1x 1x 1x 1x 1x 1x 1x 10x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x | import { sspi, sysinfo, adsi } from '../../lib/api'; import { IADsContainer, IDirectorySearch, IDispatch } from '../../lib/adsi'; import { openADConnection, closeADConnection } from './adConnection'; /** * Get the domain (Microsoft domain) or hostname (workgroup) of this machine. * * @returns {string} domain name */ export function getDefaultDomain(): string { const str = sspi.GetUserNameEx('NameSamCompatible'); const domain = str.split('\\')[0]; return domain; } /** * Want to know if your computer has joined a Microsoft Windows domain ? * * @export * @returns {boolean} true if this computer joined a domain, false otherwise. */ export function isOnDomain(): boolean { return sysinfo.GetComputerNameEx('ComputerNameDnsDomain').length > 0; } export function isActiveDirectoryReachable(): boolean { let gc!: IADsContainer; let element!: IDispatch; let ds!: IDirectorySearch; try { openADConnection(); gc = adsi.ADsOpenObjectSync<IADsContainer>({ binding: 'GC:', riid: 'IID_IADsContainer', }); element = gc.Next(); ds = element.QueryInterface('IID_IDirectorySearch'); } catch (e) { return false; } finally { ds?.Release(); element?.Release(); gc?.Release(); closeADConnection(); } return true; } |