How should I architect serperate login areas / web applications using the same membership provider?

StackOverflow https://stackoverflow.com/questions/21446118

Вопрос

I currently have a web application, lets call it "WebApp-A".

WebApp-A implements the AspNetSqlMembershipProvider and AspNetSqlRoleProvider.

I now want to create a second web application, lets call it "SubApp-B" and have it nested inside WebApp-A as such:

WebApp-A/SubApp-B

I would like SubApp-B to implement the same AspNetSqlMembershipProvider and AspNetSqlRoleProvider.

I would like users created under SubApp-B to be able to log into WebApp-A, but users created under WebApp-A to NOT be able to log into SubApp-B. I would also like to be able to assign roles from WebApp-A to SubApp-B users.

To my understanding I can use the same AspNetSqlMembershipProvider with multiple web applications and differentiate users using the applicationName="" inside of the respective web.config's. Would this approach satisfy my above requirements?

Should I even be nesting SubApp-B as a web-application inside WebApp-A. OR should I just be using WebApp-A with roles to create users that can access the /SubFolder area?

Это было полезно?

Решение

I would like users created under SubApp-B to be able to log into WebApp-A, but users created under WebApp-A to NOT be able to log into SubApp-B. I would also like to be able to assign roles from WebApp-A to SubApp-B users.

If a user is created under SubApp-B, then assign a special role (let say SubAppBRole) to the user .

When a user access SubApp-B, check to make sure the user is in the SubAppBRole.

In other words, a user created under WebApp-A are not in SubAppBRole, and they won't be able to loing to SubApp-B

To my understanding I can use the same AspNetSqlMembershipProvider with multiple web applications and differentiate users using the applicationName="" inside of the respective web.config's. Would this approach satisfy my above requirements?

No. You cannot set WebApp-A and SubApp-B in different ApplicaitionName. If you want a WebApp-A user to be able to log-in to SubApp-B, the user needs to be in same ApplicaitionName.

Should I even be nesting SubApp-B as a web-application inside WebApp-A. OR should I just be using WebApp-A with roles to create users that can access the /SubFolder area?

You can nest two ASP.Net sites although I personally do not like it. Sometime, FormAuthentication domain gives problem if you try SSO. Besides, configuration setting in two web.config files might collide each other. However, once you configure it properly, it should be fine.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top