Hi Jeff,
First of all, you're not comparing against the current principal - you're
comparing against the WindowsBuiltInRole enumeration. Try this instead of
the Enum.GetValues method and everything that follows:
return myPrincipal.IsInRole(sRoleName);
foreach (object roleName in wbirFields)
{
// error on the next line
if ( System.String.Compare( roleName, sRoleName, true ) == 0 )
The exception is occuring because roleName is typed as System.Object and the
Compare method expects System.String.
In the future you should post the exception message and strack trace as
well.
--
Dave Sexton
"Jeff Williams" <je***********@hardsoft.com.auwrote in message
news:12*************@corp.supernews.com...
How do I compare a array string value with an string
private bool CheckRole( string sRoleName )
{
bool lIsInRole;
lIsInRole = false;
AppDomain myDomain = Thread.GetDomain();
myDomain.SetPrincipalPolicy(PrincipalPolicy.Window sPrincipal);
WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole));
foreach (object roleName in wbirFields)
{
// error on the next line
if ( System.String.Compare( roleName, sRoleName, true ) == 0 )
{
lIsInRole = true; } }
return lIsInRole;
}