MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Account Activation (Closed) (Mono Support )

Viewed 39902 time(s), 5 post(s) 9/20/2011 8:58:36 AMby whitewing

Related topics

whitewing

whitewing

9/20/2011 8:58:36 AM
Hello

I use Active Directory login for user, but if user doesn't login, user doesn't have account data in database, user profile doesn't work.

so what kind of method, I can replace user login? or use API to insert data ? I hope user doesn't login , user profile can work.
This content has not been rated yet. 
105 Reputation 12 Total posts
khorvat

khorvat

9/20/2011 9:20:58 AM
Hi,

Can you please provide us with the exception you get from the User profile module ?

if you have AD, Windows authentication and ASP.NET impersonation turned on then your users are automatically authenticated. In that case you need to call the following method in some Web site entry point:

UserRepository repository = UserRepository.GetInstance();
AspnetUsersEntity authenticatedUser = repository.GetUser(this.Page.User.Identity.Name);
if (authenticatedUser == null)
{
    if (!repository.CreateUserManually(this.Page.User.Identity.Name))
    {
        //Your error custom message
        return;
    }
}
MonoSoftware.MonoX.BusinessLayer.UserProfileBLL.GetInstance().GetCachedUserProfile(SecurityUtility.GetUserId());

If you need further help let us know.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
denis

denis

9/20/2011 10:21:27 AM
You are correct, AD users are created in the database for the first time they log in. It is just a "placeholder" account for the referential integrity and additional profile field purposes, the actual authentication still takes place at AD server.
If you still need to have accounts for AD users that never log in to the system, you will have to insert them manually, using the method Kristijan mentioned.
This content has not been rated yet. 
7207 Reputation 956 Total posts
whitewing

whitewing

9/23/2011 2:06:30 AM

Thanks denis and khorvat give me a method to do this.

Below is my code to use AD Account Activation Before user login first

public void AccountActivation(string UserName) {
  
        UserRepository repository = UserRepository.GetInstance();
  
        AspnetUsersEntity authenticatedUser = repository.GetUser(UserName);
  
        if (authenticatedUser == null)
        {
            repository.CreateUserManually(UserName);
        }
 }
This content has not been rated yet. 
105 Reputation 12 Total posts
khorvat

khorvat

9/23/2011 6:33:46 AM
Hi,

I'm glad that you have solve the issue, and if you need further assistance let us know, for now we are closing this topic a you have flagged it as answered. 

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts