MSDN > フォーラム ホーム > Visual Basic Language > Question about: My.User.IsInRole
質問する質問する
 

全般的な情報交換Question about: My.User.IsInRole

  • 2008年4月11日 15:50dfschrader ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    I hope this is the right place for this question - I haven't found
    any other group whose name even vaguely would seem likely
    as a place to ask this question.

     

    I'm working on a (VS2008) VB program. It is likely that any
    number of people might be able to access the program but I
    wish to control what (specifically) they can do by using their
    membership in either a local or domain group.

     

    VS2008 makes available the "IsInRole" construct which when
    called returns a T/F if the current authenticated machine user
    is a member of one of a set of local, domain, or global groups.

     

    It is used as follows:

         If My.User.IsInRole( _
              ApplicationServices.BuiltInRole.Administrator ) Then
           ' Whatever code is to be executed...
         End If

     

    This works perfectly as long as the "role" is one of the VS2008
    (and NT) standard groups - Administrator, BackUpOperator,
    etc. Unfortunately, these doesn't seem to be any method/way
    to specify a group which might be created for this purpose,
    like "SiteCoordinator" or "SeniorMonitor."

     

    Is anyone familiar with either how this construct can be used
    to determine membership in a created group or of some other
    method (preferably in VB) which can be called via a VB
    program and determine whether an individual is a member of
    a group - local, domain or global - or not?

     

    Thanks.

すべての返信

  • 2008年4月15日 13:57Riquel_Dongモデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hi ,

    You need to use role-based security mechanism in this scenario to authenticate the user. Commonly you can use the following code snippet to authenticate a user.

    Dim principal As IPrincipal

    principal = System.Threading.Thread.CurrentPrincipal

    principal.IsInRole("your group name")


    Best regards,
    Riquel
  • 2008年4月18日 2:13Riquel_Dongモデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions. Thank you!
  • 2008年5月15日 19:54dfschrader ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Got hit by a virelent bug so this is my first chance to see these responses. I will try it tonight or tomorrow and get back with a report on what happens.

     

    David

     

  • 2008年5月16日 19:38dfschrader ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Well, I had a chance to try suggestion which was offered but, while it made good sense I haven't yet been able to get any code working. (I've read and tried most if not all of the on-line examples and they all are either insufficient (in details) or (apparently) flat out don't work. I haven't given up but I will keep working on it although I may move other elements of the project closer to the burner.

     

    My thanks. Maybe there'll be a miraculious (ok spekk since that doesn't look spelled correctly) happening which will pour out perfectly working code.

     

    David

     

    (Boy I wish this thing had a spelling checker built into it!)

  • 2008年7月3日 17:06dfschrader ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Raquel,

    You were kind enough to reply to an earlier question (about role based security - which I still haven't really gotten working, but...) amd I am hoping that perhaps you can direct me on another item.

    If you select the "File" option from the system menu and choose to create a new folder (File|New|Folder) you always get a (an empty) folder of the same size (displayed). Are you aware of any method of altering the size (registry or otherwise) of the folder?

    In conjunction with that, there are COM items (I suppose) that plave an *.ini* file within the a folder which contains the name of an icon file (or dll and icon number) which is displayed as the folder's icon.

    Might there be aware of some means which could store the folder's "height" and "width" in the same sort of file so that it would always be restored hack to the same sife? Being able to post the X and Y
    location there as well would be a nice touch.

    Thanks.

    David
    David Schrader