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

  • SEARCH
  • Home
  • 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 6841435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:57:58+00:00 2026-05-26T23:57:58+00:00

I’ll need to preface this with the fact that I am a complete newbie

  • 0

I’ll need to preface this with the fact that I am a complete newbie when it comes to nhibernate, and I don’t know what I don’t know.

I have a user class like so:

public class nhMembershipUser : MembershipUser
{
    public new virtual Guid ProviderUserKey { get; set; }
    public new virtual DateTime LastPasswordChangedDate { get; set; }
    public virtual bool IsEnabled { get; set; }
    protected internal virtual byte[] Password { get; set; }
    protected internal virtual string Salt { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
    public virtual string Application { get; set; }
    public new virtual string UserName { get; set; }
    public override bool IsOnline
    {
        get
        {
            var UnitOfWork = new nhUnitOfWork();
            return UnitOfWork.UserIsOnline(this);
        }
    }
    public new virtual bool IsLockedOut { get; set; }
    public virtual IList<nhRole> Roles { get; set; }

}

… and a fluent mapping class like so:

public class nhMembershipUserMap : ClassMap<nhMembershipUser>
{
    public nhMembershipUserMap()
    {
        Table("Users");
        Id(x => x.ProviderUserKey).Column("UserID");
        Map(x => x.Comment).Nullable().Length(10000);
        Map(x => x.CreationDate).CustomType<UtcDateTimeType>().Not.Nullable();
        Map(x => x.Email).Not.Nullable().Length(250);
        Map(x => x.IsApproved).Default("1");
        Map(x => x.IsLockedOut).Default("0");
        Map(x => x.LastActivityDate).Nullable();
        Map(x => x.LastLockoutDate).Nullable();
        Map(x => x.LastLoginDate).Nullable();
        Map(x => x.LastPasswordChangedDate).Nullable();
        Map(x => x.PasswordQuestion).Nullable().Length(250);
        Map(x => x.ProviderName).Default("").Not.Nullable().Length(250);
        Map(x => x.UserName).Not.Nullable().Length(250);
        Map(x => x.IsEnabled).Default("1").Not.Nullable();
        Map(Reveal.Member<nhMembershipUser>("Password")).Length(260).Nullable();
        Map(Reveal.Member<nhMembershipUser>("Salt")).Length(250).Nullable();
        Map(x => x.FirstName).Length(35).Not.Nullable();
        Map(x => x.LastName).Length(35).Not.Nullable();
        Map(x => x.Application).Length(250).Not.Nullable();
        HasManyToMany(x => x.Roles).ChildKeyColumn("RoleId").ParentKeyColumn("UserId").Cascade.All().Table("UsersToRoles");

    }
}

This builds, but of course I can’t get or set the Salt or Password properties outside the class, which is bogus. I’m trying to keep my user class light and POCO-ish and build the salting and hashing functionality into my membership provider; I really don’t want the public having access but I want my provider class to. The obvious answer is to use an internal access modifier but NH barks at me when I do that without a protected modifier and that defeats the purpose.

How can I have another class in my assembly access these restricted properties and save to NHibernate? It seems like this should be easily doable.

  • 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-26T23:57:59+00:00Added an answer on May 26, 2026 at 11:57 pm
    public class nhMembershipUser : MembershipUser
    {
        private byte[] PasswordHash;
        private string Salt;
    
        public void SetPassword(ICredentialsProvider provider)
        {
            PasswordHash = provider.GetHash(this);
            Salt = provider.GetSalt(this);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.