Mono Support Account Activation (Closed)

Viewed 71667 time(s), 5 post(s), 9/20/2011 8:58:36 AM - by whitewing
9/20/2011 8:58:36 AM
105 Reputation 12 Total posts

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.

1
9/20/2011 9:20:58 AM
15993 Reputation 2214 Total posts

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

2
9/20/2011 10:21:27 AM
7207 Reputation 956 Total posts

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.

3
9/23/2011 2:06:30 AM
105 Reputation 12 Total posts

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);
        }
 }

4
9/23/2011 6:33:46 AM
15993 Reputation 2214 Total posts

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

5
This is a demo site for MonoX. Please visit Mono Software for more info.