I am trying to set the value of an extension attribute in AD with my VB.NET executable. I extended the UserPrincipal
class to accomplish this but now I get an error
The server is unwilling to process the request
when I try to set the extended property.
I can get that property from an existing user in AD without any errors and when I try to create and save the user without the extended class it works.
Dim stringDomainName As String = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName
Dim objPrincipalContext As New PrincipalContext(ContextType.Domain, stringDomainName, DirectoryPath, ContextOptions.SimpleBind, DomainUsername, DomainPassword)
Dim objUserPrincipal As New UPExtention(objPrincipalContext, sUserName, sPassword, True)
Dim expDate As Date
'Set Name
objUserPrincipal.Name = sFirstName & " " & sLastName
'Set First Name
objUserPrincipal.GivenName = sFirstName
'Set Last Name
objUserPrincipal.Surname = sLastName
'Set Display Name
objUserPrincipal.DisplayName = sLastName & ", " & sFirstName
'Enable Account
objUserPrincipal.Enabled = True
objUserPrincipal.extentionAttribute15 = sUserName
'Save the created user
objUserPrincipal.Save(objPrincipalContext)