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 (Zatvorena) (Mono Support )

72458 put(a) pogledan, 5 odgovor(a) 20.9.2011. 8:58:36Kreirao(la) whitewing

Povezane teme

whitewing

whitewing

20.9.2011. 8:58:36
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.
Ovaj sadržaj još nije ocijenjen. 
105 Reputacija 12 Ukupno objava
khorvat

khorvat

20.9.2011. 9:20:58
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
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
denis

denis

20.9.2011. 10:21:27
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.
Ovaj sadržaj još nije ocijenjen. 
7207 Reputacija 956 Ukupno objava
whitewing

whitewing

23.9.2011. 2:06:30

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);
        }
 }
Ovaj sadržaj još nije ocijenjen. 
105 Reputacija 12 Ukupno objava
khorvat

khorvat

23.9.2011. 6:33:46
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
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava