private bool TryAddUrlReservations() { var user = WindowsIdentity.GetCurrent().Name; foreach (var prefix in GetPrefixes()) { // netsh http add urlacl url=http://+:222222/test // netsh http add urlacl url=http://+:222222/test user=domain\user if (!NetSh.AddUrlAcl(prefix, user)) { return(false); } } return(true); }
private bool TryAddUrlReservations() { var urlReservations = new UrlReservations(); var user = !string.IsNullOrWhiteSpace(urlReservations.User) ? urlReservations.User : WindowsIdentity.GetCurrent().Name; foreach (var prefix in GetPrefixes()) { // https://msdn.microsoft.com/en-us/library/windows/desktop/cc307223(v=vs.85).aspx // Reserves the specified URL for non-administrator users and accounts. // The discretionary access control list (DACL) can be specified by using an account name // with the listen and delegate parameters or by using a security descriptor definition language (SDDL) string. // netsh http add urlacl url=http://+:3202/MyUri // netsh http add urlacl url=http://+:3202/MyUri user=DOMAIN\user // netsh http delete urlacl url=http://+:3202/MyUri if (!NetSh.AddUrlAcl(prefix, user)) { return(false); } } return(true); }