private void RequestAdminRights(string hostName) { string remoteHostAddress = string.Format("net.tcp://{0}/MakeMeAdmin/Service", hostName); NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport); ChannelFactory <IAdminGroup> namedPipeFactory = new ChannelFactory <IAdminGroup>(binding, remoteHostAddress); IAdminGroup channel = namedPipeFactory.CreateChannel(); try { channel.AddPrincipalToAdministratorsGroup(); } catch (System.ServiceModel.EndpointNotFoundException) { throw; } catch (Exception) { throw; // TODO: What do we do with this error? } }
private void addUserBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport); ChannelFactory <IAdminGroup> namedPipeFactory = new ChannelFactory <IAdminGroup>(binding, Shared.NamedPipeServiceBaseAddress); IAdminGroup channel = namedPipeFactory.CreateChannel(); try { channel.AddPrincipalToAdministratorsGroup(); } catch (System.ServiceModel.EndpointNotFoundException) { throw; } catch (Exception) { throw; // TODO: What do we do with this error? } namedPipeFactory.Close(); }