Q: While trying to enable a user for Lync, I get an error that the user does not have a UserPrincipalName--what can I do?

A: A valid UserPrincipalName (UPN) attribute value should look like an email address (e.g., john@savilltech.net). If while you are trying to enable a user for Lync

PS C:\> Enable-CsUser -Identity 'John Savill' -RegistrarPool savdalync01.savilltech.net -SipAddressType EmailAddress

you are receiving the error below, the likelihood is the user's UPN is not valid.


Enable-CsUser : ConstraintViolationStringDoesNotMatchRegularExpression(Pattern
that specifies a valid UserPrincipalName, john)
At line:1 char:1
+ Enable-CsUser -Identity 'John Savill' -RegistrarPool
savdalync01.savilltech.net  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Enable-CsUser], Exception
    + FullyQualifiedErrorId : Validation,Microsoft.Rtc.Management.AD.Cmdlets.E
   nableOcsUserCmdlet

Enable-CsUser : ConstraintViolationStringDoesNotMatchRegularExpression(Pattern
that specifies a valid UserPrincipalName, john)
At line:1 char:1
+ Enable-CsUser -Identity 'John Savill' -RegistrarPool
savdalync01.savilltech.net  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Enable-CsUser], Exception
    + FullyQualifiedErrorId : Validation,Microsoft.Rtc.Management.AD.Cmdlets.E
   nableOcsUserCmdlet

In the example above, the user's UPN is "john," which isn't a valid UPN. The easiest way to confirm and fix it is by using ADSIEdit.msc on a domain controller (DC).

Make sure the user has a valid UPN value. In the screen shot below, the value was "john" and I'm changing it in the String Attribute Editor to "john@savilltech.net" (where savilltech.net is the name of the user's domain).

upnfixadsieditsml
Fixing the UPN in the Attribute Editor

After the UPN is fixed, the command below to enable the user for Lync works without error (I'm using Windows PowerShell, as this user is a domain admin so the normal GUI doesn't work).

 

PS C:\> Enable-CsUser -Identity 'John Savill' -RegistrarPool savdalync01.savilltech.net -SipAddressType EmailAddress