Share via

PKI - Certificate Templates: DACL assessment

49885604 235 Reputation points
2025-10-17T09:20:49.8066667+00:00

Hi everyone,

I've created a script to assess the grant on SubCA templates in the Security tab. The resulting script returns a .csv file and an .html file. Can you tell me if it's working properly for you and if it's structured and written properly?

I would need feedback to certify what has been produced.

Thanks in advance and kind regards,

Alessio.DACLTemplates.pdf

Windows for business | Windows Server | Directory services | Certificates and public key infrastructure (PKI)
{count} votes

Answer accepted by question author
  1. VPHAN 25,000 Reputation points Independent Advisor
    2025-10-17T10:10:21.0633333+00:00

    From a static code review, it should work properly in a domain environment with sufficient privileges (e.g., Domain Admin or equivalent for reading templates). The fixes mentioned in comments (e.g., UPDATE FIX 1 for WriteDacl, adding RAS and IAS Servers) show iterative improvements, addressing potential edge cases like GUI mismatches in permission display. The HTML report is particularly polished, incorporating CSS for styling, JavaScript for interactive sorting/searching/animation, and embedded stats with a simple bar chart, which adds real value for visual analysis without overcomplicating the script.

    A few minor suggestions for enhancement that you can consider: First, if the intent is specifically to assess SubCA templates (as mentioned in your query), consider adding a filter in the DirectorySearcher, such as modifying the filter to "( &(objectClass=pKICertificateTemplate)(cn=SubCA) )" or parameterizing it to target specific templates like "SubCA" or "Subordinate Certification Authority." Currently, it processes all templates, which is fine for a general audit but might produce broader results than needed. The granting function isn't invoked in the main script—it's commented out as an example, which is good for safety, but you could add a switch parameter to optionally run it. For robustness, include checks for running as administrator (e.g., using [Security.Principal.WindowsPrincipal]) and perhaps log detailed errors to a file instead of just Write-Error. Finally, while the HTML bars use a fixed color (#2e7d32), consider dynamic coloring based on permission type for better distinction.

    However, to truly certify its functionality, I'd recommend testing it in a non-production AD environment—run it against known templates, verify the CSV/HTML outputs match manual checks in the Certificate Templates MMC snap-in, and confirm permissions are correctly interpreted (e.g., Enroll requires the specific GUID or ExtendedRight bit). Based on the code alone, it looks reliable and production-ready with those tweaks.

    VP


4 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. VPHAN 25,000 Reputation points Independent Advisor
    2025-10-22T22:28:07.81+00:00

    Hi 49885604,

    Has your issue been solved? If it has, please accept the answer so that others can benefit too. If not, is there anything I can help you with? Please let me know.

    Vivian

    0 comments No comments

  4. 49885604 235 Reputation points
    2025-10-20T11:18:06.2466667+00:00

    Does anyone else have any suggestions or post-audit analysis?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.