Re: Role based security on local machine

From: Nicole Calinoiu (calinoiu)
Date: 04/29/05


Date: Fri, 29 Apr 2005 08:35:05 -0400

Is the "MACHINENAME" from your sample code the name of the local machine or
another machine on the network? If it's the local machine, try using the
"BUILTIN\Administrators" syntax instead. If it's not the local machine, is
it possible that your local account doesn't have permissions to access the
target machine at all?

"Diane" <dweaver@hcd.net> wrote in message
news:1114774743.636573.247460@o13g2000cwo.googlegroups.com...
>I am testing role based security and have a problem when logged into
> the local machine. It always fails when I specify a group instead of a
> user name. Everything works fine when I'm logged into the domain. I'm
> running it on an XP machine. Following is the code:
>
> Dim currentDomain As AppDomain = AppDomain.CurrentDomain
>
> currentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
>
> Dim myIdentity As WindowsIdentity = WindowsIdentity.GetCurrent
> Dim myPrincipal As New WindowsPrincipal(myIdentity)
> Thread.CurrentPrincipal = myPrincipal
>
> Dim myPermission As New PrincipalPermission(Nothing,
> "MACHINENAME\Administrators")
>
> Try
> myPermission.Demand()
> MessageBox.Show("Welcome to the show! You have access!")
> Catch ex As Exception
> MessageBox.Show("Get out of here! You don't have access!")
> MessageBox.Show(ex.Message)
> End Try
>



Relevant Pages

  • VB6 DirectoryFile Maintenance
    ... there's a file on my local machine which gets backed up ... every night to the network server with the name datetime.BAK. ... Does anyone have a suggestion as to how I should go ... And if sample code is available, ...
    (microsoft.public.vb.general.discussion)
  • Re: Get current IP address
    ... Dim defaultIPAddress As String = ... > Does anyone have sample code on how to get the current IP address of a ...
    (microsoft.public.dotnet.languages.vb)
  • Get current IP address
    ... Does anyone have sample code on how to get the current IP address of a ... how would you ping your own machine and get the IP address of it ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ASP.Net Connection To MYSQL
    ... databases are local to this machine, if not connected to the network, ... extremely fast so it is possible that your problem lies elsewhere. ... I am developing on a local machine. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IDE changes setting on its own
    ... This may be an artifact of something happening on your local machine or network, rather than a "bug" in VS. ... > "Start page" to "Empty environment". ... > get a bug fix? ...
    (microsoft.public.vsnet.ide)