DCSIMG
Getting builtin group name - then [net fx 1.0] and now [net fx 2.0] - אליק לוין

אליק לוין

עולמו של יועץ ממיקרוסופט

Getting builtin group name - then [net fx 1.0] and now [net fx 2.0]

I was asked some time ago on how to get built in group names. Suppose one needs to get the name of System.Security.Principal.WindowsBuiltInRole.PowerUser. Why? Say there is a need to get it right on different platforms - Englsih, German, etc. Back in the days I used reflection to accomplish this:

                                    Type t = typeof(WindowsPrincipal);

 

                                    int rid = (int)WindowsBuiltInRole.PowerUser;

 

                                    object[] args = new object[1];

                                    args[0] = rid;

 

                                    string role = (string)t.InvokeMember("_GetRole",

                                                                        BindingFlags.Static |

                                                                        BindingFlags.NonPublic |

                                                                        BindingFlags.InvokeMethod,

                                                                        null,

                                                                        null,

                                                                        args);

Now [net fx 2.0] it is much easier and more important it is supported and one can use WellKnownSidType from System.Security.Principal namespace

 

http://msdn2.microsoft.com/en-US/library/system.security.principal.wellknownsidtype(VS.80).aspx

 

Also check on Keith Brown's relevant content:

 

http://www.pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToProgramWithSIDs.html

 

My favorite from there is "The day I write my last line of C code will be a very happy day for me!"

פורסם: Apr 21 2006, 02:36 PM by alikl | with no comments