I keep getting the error for UnauthorizedAccessException and I am wondering if there is a way around this.
Here is the chunk of code where the error comes from. If someone could help me with this it would be very much appreciated.
public List<String> GetConnections()
{
dynamic everyConnection = null;
dynamic connectionProp = null;
List<string> connections = new List<string>();
everyConnections = netSharingManager.EnumEveryConnection; // <<< UnathorizedAccessException
foreach (dynamic connection in everyConnections)
{
everyConnection = netSharingManager.INetSharingConfigurationForINetConnection(connection);
connectionProp = netSharingManager.NetConnectionProps(connection);
connections.Add(connectionProp.Name);
}
return connections;
}