Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3497562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:23:08+00:00 2026-05-18T12:23:08+00:00

I have a web app that uses some backend servers (UNC, HTTP and SQL).

  • 0

I have a web app that uses some backend servers (UNC, HTTP and SQL). To get this working I need to configure ServicePrincipalNames for the account running the IIS AppPool and then allow kerberos delegation to the backend services.

I know how to configure this through the “Delegation” tab of the AD Users and Computers tool.

However, the application is going to be deployed to a number of Active Directory environments. Configuring delegation manually has proved to be error prone and debugging the issues misconfiguration causes is time consuming. I’d like to create an installation script or program that can do this for me.

Does anyone know how to script or programmatically set constrained delegation within AD?

Failing that how can I script reading the allowed services for a user to validate that it has been setup correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:23:08+00:00Added an answer on May 18, 2026 at 12:23 pm

    OK, after much digging on the internet and some testing, I’ve got a way forward.

    The following code is c#.
    Setting an SPN for a user or computer can be achieved via the setspn utility.

    Alternatively, the following C# code can do the same:

    DirectoryEntry de = new DirectoryEntry("LDAP://"+usersDN);
    
    if (!de.Properties["servicePrincipalName"].Contains(spnString))
    {
        de.Properties["servicePrincipalName"].Add(spnString);
        de.CommitChanges();
    }
    

    To set constrained delegation:

    if (!de.Properties["msDS-AllowedToDelegateTo"].Contains(backendSpnString))
    {
        de.Properties["msDS-AllowedToDelegateTo"].Add(backendSpnString);
        de.CommitChanges();
    }
    

    If the user has had non-constrained delegation enabled, you may need to turn this off before enabling constrained – but I didn’t fully test this scenario.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have developed a .NET web application that uses SQL Server as a backend.
I have a fairly simple web app that uses cookies to store some information
Problem: We have a web app that calls some web services asynchronously (from the
I have this .NET web app that draws a table in Page_Load. Then after
This a bit of strange one.... We have an internal web app that runs
I have a Web Forms app that uses forms authentication. I have a Crystal
I have a web app that currently uses the current HttpContext to store a
I have a web app that uses Spring's Log4jConfigurer class to initialize my Log4J
I have a web app that is heavily loaded in javascript and css. First
I have a web app that only registered users can use, therefore I should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.