Question: So I'm creating a AD User with the UserPrincipal Class but I can't set the Allow Dial-In Setting through that. 

How can I enable the setting?

Thanks in advance!

Answer: 
You cannot set all Properties in the UserPrincipal class. This could give an idea how to do it with the help of the **DirectoryEntry** class:

```
//Get the Directory entry of your Userprincipal
DirectoryEntry directoryEntry = [YOUR_USERPRINCIPAL_OBJECT].GetUnderlyingObject() as DirectoryEntry;

//Set Allow Dialin attribute
directoryEntry.Properties["msNPAllowDialin"].Value = false;

//Save changes
directoryEntry.CommitChanges();

```

Hope this helps
If you want you can use UserPrincipal to read and write DialIn option using [user principal extension](http://blogs.msdn.com/b/kaevans/archive/2012/04/11/querying-active-directory-using-principal-extensions-in-system-directoryservices-accountmanagement.aspx) 

You can create your extended user principal like this

```
        [DirectoryObjectClass("user")]
        [DirectoryRdnPrefix("CN")]

        public class UserPrincipalExtension : UserPrincipal
        {
            public UserPrincipalExtension(PrincipalContext context) : base(context) { }

            public UserPrincipalExtension(PrincipalContext context, string samAccountName, string password, bool isEnabled)
                : base(context, samAccountName, password, isEnabled)
            {
            }

            [DirectoryProperty("msNPAllowDialin")]
            public bool? DialIn
            {
                get
                {
                    if (ExtensionGet("msNPAllowDialin").Length != 1)
                        return null;

                    return (bool?)ExtensionGet("msNPAllowDialin")[0];

                }
                set { this.ExtensionSet("msNPAllowDialin", value); }
            }
    }

```

Then you can set the attribute

```
//this code will create a new user on AD
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "SharePoint", "OU=Employees,DC=SharePoint,DC=Com"))
{
    using (UserPrincipalExtension up = new UserPrincipalExtension(context))
    {
        //Set all others properties
        up.DialIn = true; //true = Allow access, false = Deny access, null = control access through policy
        up.Save();
     }
 }

//this code will update a user
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "SharePoint", "OU=Employees,DC=SharePoint,DC=Com"))
{
    using (UserPrincipalExtension up = UserPrincipalExtension.FindByIdentity(context, samAccountName))
    {
       //Set all others properties
       up.DialIn = true; //true = Allow access, false = Deny access, null = control access through policy
       up.Save();
    }
}

```