How would I change User Principal Name to SamAccountName?

Aug 21, 2013 at 7:01 PM
How would I change User Principal Name to SamAccountName?
Dec 9, 2013 at 4:57 PM
In homecontroller.cs, I changed

var userPrincipal = UserPrincipal.FindByIdentity(principalContext, model.UserPrincipalName);
var userPrincipal = UserPrincipal.FindByIdentity(principalContext, model.SAMNAME);

Then I made a change to changepasswordmodel.cs.
    [Required, Display(Name = "User ID")]
    public string SAMNAME { get; set; }
Then changed index.cshtml to
@{ currentFieldName = "SAMNAME"; }
<div class="control-group @(this.HasErrors(currentFieldName) ? "error" : string.Empty)">
    <label class="control-label" for="@currentFieldName">SSO</label>
    <div class="controls error">
        <input class="input-xlarge" type="text" id="@currentFieldName" name="@currentFieldName" placeholder="Example: HDerping" value="@Model.SAMNAME" />
        @if (this.HasErrors(currentFieldName))
            <span class="help-inline">@ErrorMessage(currentFieldName)</span>
I changed the vars from mine for clarity, so it "should" still work, but you get the idea...
Dec 28, 2013 at 4:52 PM
Nice tip HatBeard!
Feb 5, 2014 at 9:56 AM
Can you please tell me where are those two .cs files, "changepasswordmodel.cs" and "homecontroller.cs".
To make it simple for my domain users, is better to use SAMACCOUNTNAME.
Thank you so much.
Feb 5, 2014 at 4:32 PM
you will need to get the source and compile it yourself in order to change those files. Hope it helps.
Feb 5, 2014 at 9:49 PM
Thank you for your quick reply. Already in the process of compiling the source. Just need to repeat it, i believe i have to chose a different path for saving complied code, the first time it mixed up compiled code and the source. You have helped me a lot, thank you again,


Feb 26, 2014 at 6:07 AM
Looks like a realy god prodject. i trie to open the source in VS2012 but gets only errors. so i wonder if some one could post the buildt site with SAMACCOUNT
then i would be wery happy :)

Sep 9, 2014 at 5:44 AM
Here's the changed source code and ready-to-go web files for SAMAccountName