views:

28

answers:

1

When supplying the string value for this windows principal method .... do you always to supply the Domain also or can you just supply the Group's name and thats abt it???

MSDN:

//Get the role using the string value of the role.
Console.WriteLine("{0}", myPrincipal.IsInRole("BUILTIN\\Administrators"));
Console.WriteLine("{0}", myPrincipal.IsInRole("BUILTIN\\Users"));

// I have cut it down to make it fit on one line??? // it's going to return true or false i know that but is the usage of the method correct????

Can you someone please clear this up for me ... as then i wil know why I was wrong or potentially right (saw it on the exam)??? I am of the impression that you always need to supply domain informatiom followed my group name or username??? Is this correct?

A: 

You always supply the domain.

The place where you got your code sample, clearly states its a "Windows" domain.

When looking up a group it resolves to local domain.

Console.WriteLine("{0}", myPrincipal.IsInRole("Users"));

Would check your local computer.

  Console.WriteLine("{0}", myPrincipal.IsInRole(Environment.UserDomainName + "\\Users"));

Would check against the domain.

Nix
I don't think that this is in any way related to asp.net.
Sky Sanders
You are right, totally glanced over the first part of the code sample.
Nix
@ Nix, thanks for this. I just need more people to comment now. Also my question is related to windows systems.
IbrarMumtaz
@ Nix, oooh sorry i may have omitted that by mistake ... yeah i am talking about in the context of windows domains and windows based systems as mentioned in my previous comment. I just want to know if Domain that a user name resides in or under can be inferred by the compiler must we always be explicit or fully qualify groups with their domain prefixes???
IbrarMumtaz