Mono Support Account Activation (Zatvorena)

76068 put(a) pogledan, 5 odgovor(a), 20.9.2011. 8:58:36 - Kreirao(la) whitewing
20.9.2011. 8:58:36
105 Reputacija 12 Ukupno objava

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
20.9.2011. 9:20:58
15993 Reputacija 2214 Ukupno objava

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
20.9.2011. 10:21:27
7207 Reputacija 956 Ukupno objava

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
23.9.2011. 2:06:30
105 Reputacija 12 Ukupno objava

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
23.9.2011. 6:33:46
15993 Reputacija 2214 Ukupno objava

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
Ovo je MonoX demo site. Posjetite Mono Software za više detalja.