I'm trying to figure out if a user has admin rights on a particular server by calling the following code:
<!-- language: lang-vb -->Dim serverContext As New PrincipalContext(ContextType.Machine, myServerName)
If they don't, the ConnectedServer
property on the PrincipleContext
object turns into type System.UnathorizedAccessException
and the value is {"Access is denied."}
But I can't seem to run any check in code to see if this is the case or not or wether the connected server property set normally as a string.
These won't work, and I can't figure out why
<!-- language: lang-vb -->Dim bln1 = serverContext.ConnectedServer = "Access is denied."
Dim bln2 = TypeOf serverContext.ConnectedServer Is System.UnauthorizedAccessException