none
Logic explanation RRS feed

  • Question

  • I am new to c# trying to understand the logic, can anyone please explain the below steps in detail please ?

    protected override bool CheckAccessCore(OperationContext operationContext)
            {
                //check that basic access is ok before checking our custom conditions
                if (!base.CheckAccessCore(operationContext))
                {
                    return false;
                }
    
                //print out inbound identities recorded by WCF
                System.Diagnostics.Trace.WriteLine("Primarytity is " + operationContext.ServiceSecurityContext.PrimaryIdentity.Name);
                System.Diagnostics.Trace.WriteLine("Windowstity is " + operationContext.ServiceSecurityContext.WindowsIdentity.Name);
    
              
                var UserName = ServiceSecurityContext.Current.PrimaryIdentity.IsAuthenticated;
    
    
                //create Windows principal object from inbound Windows identity
                WindowsPrincipal p = new WindowsPrincipal(operationContext.ServiceSecurityContext.WindowsIdentity);
                //check user in role
                bool isAdmin = p.IsInRole(this.m_windowsgroup);
                if (!isAdmin)
                {
                    return false;
                }
                return true;
            }


    Reason101

    Wednesday, February 26, 2020 5:34 AM

All replies

  • The code is checking  on what Windows O/S user group the logged in user logged in on the computer is part of. if the user account is part of the Windows administrator group, then true is returned out of the method, else false. This is probably called by some other code, that will allow the code to be executed by an administrator and not executable by a user that is a non administrator.
    Wednesday, February 26, 2020 6:26 AM
  • that is correct.

    I have a service hosted in IIS, first the external application is passing to the above code WindowsGroup which this code is checking and validating.

    Iam passing the Windows group as a dynamic parameter stored in SSO database,  well unless the IIS is reset it is taking the old cache value.

    I dont want to always keep restarting IIS after changing the dynamic value specially in Production.

    Is there anyway in the code I can mention logic that automatically refreshes the IIS taking the latest dynamic value mentioned in IIS ?

    Please advise


    Reason101

    Wednesday, February 26, 2020 6:38 AM
  • Hi Reason101,

    Thank you for posting here.

    The link below seems to have a problem similar to yours, and see if his solution works for you.

    Web application running on IIS caches database data

    Are you using EF? If yes, you can also look at this:

    Entity Framework Caching Issue

    Is your project an ASP.Net project?

    If so, I suggest that you can ask this question in  ASP.Net forum , they can provide more professional opinions and suggestions.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 26, 2020 9:22 AM
  • Yes, you can refresh cache for a Web service, but it's was a long time ago.

    You can discuss your issues in the ASP.NET forum for Web services.

    https://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services

    Also there are developers that frequent the IIS forms

    https://forums.iis.net/

    Wednesday, February 26, 2020 1:52 PM
  • Hi,

    Has your problem been solved?

    If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 4, 2020 9:51 AM