Results 1 to 10 of 10

Thread: [RESOLVED]ASP.NET Membership Role in Windows Application

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Resolved [RESOLVED]ASP.NET Membership Role in Windows Application

    Hi all,

    i already create new connectionstring in app.config that point to myDB
    i already create aspnet membership table in myDB using aspnet_regsql
    i already create new custom provider and set the connection string there..

    what i like to ask:
    1. why when the app start, it create new folder app_data which contain aspnetDB.mdf eventhough i already create new connection string ?

    2. why when i'm using Membership.CreateUser method, it succesfully inserted in myDB.aspnet_Users table but when i'm using Roles.CreateRole method it doesn't inserted in myDB.aspnet_Roles table?

    need insight, been troubleshoot this for 2 days

    PS: i'm using .net 4.0, sql2008, vs2010

    thanks,
    erick
    Last edited by erickwidya; Oct 4th, 2010 at 10:02 PM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ASP.NET Membership Role in Windows Application

    Are u using winforms or asp.net?
    Your problem is proly the config file.
    You said you have created a custom provider.Have done for both membership and roleManager ?
    Can you show us what you have done?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: ASP.NET Membership Role in Windows Application

    Quote Originally Posted by sapator View Post
    Are u using winforms or asp.net?
    Your problem is proly the config file.
    You said you have created a custom provider.Have done for both membership and roleManager ?
    Can you show us what you have done?
    thx sapator

    i'm using winforms
    here is my custom provider
    Code:
    public class mySQLMembership : SqlMembershipProvider
        {
            public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
            {
                base.Initialize(name, config);
    
                // Update the private connection string field in the base class.
                string connectionString = myConnectionString here;
    
                // Set private property of Membership provider.
                FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
                connectionStringField.SetValue(this, connectionString);
            }
    
        }
    here is section in app.config
    Code:
      <membership defaultProvider="mySQLMembership">
          <providers>
            <clear />        
            <add name="mySQLMembership" 
                 type="DGex.Business.mySQLMembership, DGex.Business" 
                 connectionStringName="DGexEntities" 
                 enablePasswordRetrieval="false" 
                 enablePasswordReset="true" 
                 requiresQuestionAndAnswer="false" 
                 applicationName="/DGex" 
                 requiresUniqueEmail="false" 
                 passwordFormat="Hashed" 
                 maxInvalidPasswordAttempts="5" 
                 minRequiredPasswordLength="1" 
                 minRequiredNonalphanumericCharacters="0" 
                 passwordAttemptWindow="10" 
                 passwordStrengthRegularExpression="" />
          </providers>        
        </membership>
          <roleManager enabled="true"></roleManager>
    Have done for both membership and roleManager ? -> hm, we need to create our own custom membership and rolemanager?? i'm not done that..i'm using Roles and Membership class to create role, user, etc..am i doing wrong?

    basically i want to use this provider but i need it to point to real SQL DB, not using SQL Express aspnetDB.mdf

    PS: oopss just realize i post at wrong forum..sorry, can moderator move it..sorry for the trouble

    thx
    Last edited by erickwidya; Oct 4th, 2010 at 09:03 PM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ASP.NET Membership Role in Windows Application

    You need a role provider,yes.
    An example:
    Code:
    <roleManager defaultProvider="RoleProvider" enabled="true">
                <providers>
                    <clear/>
                    <add name="RoleProvider" connectionStringName="myConnectionString" applicationName="MyApplication" type="System.Web.Security.SqlRoleProvider"/>
                </providers>
            </roleManager>
            <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
    .....etc
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: ASP.NET Membership Role in Windows Application

    Quote Originally Posted by sapator View Post
    You need a role provider,yes.
    An example:
    Code:
    <roleManager defaultProvider="RoleProvider" enabled="true">
                <providers>
                    <clear/>
                    <add name="RoleProvider" connectionStringName="myConnectionString" applicationName="MyApplication" type="System.Web.Security.SqlRoleProvider"/>
                </providers>
            </roleManager>
            <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
    .....etc
    yes, finally it working...silly me, i thought it's only using rolemanger enabled="true"

    thx for pointing me at correct direction sapator

    but it still create app_bin folder which contain aspnetdb.mdf..why?

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ASP.NET Membership Role in Windows Application

    Since u use a custom Mysql i cannot be sure since i only have used strait SQL.I'll investigate a little and if i find anything i will post it.But i think the people on the local asp thread can give you a correct answer.
    For a quick test try to change your "type" to the standard mysql type.Here is an example in sql server, just use the mysql credentials
    Code:
    <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString"
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: ASP.NET Membership Role in Windows Application

    Quote Originally Posted by sapator View Post
    Since u use a custom Mysql i cannot be sure since i only have used strait SQL.I'll investigate a little and if i find anything i will post it.But i think the people on the local asp thread can give you a correct answer.
    For a quick test try to change your "type" to the standard mysql type.Here is an example in sql server, just use the mysql credentials
    Code:
    <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString"
    already use the default provider value, only change in connectionstring
    Code:
    <system.web>
            <membership defaultProvider="AspNetSqlMembershipProvider">
                <providers>
                    <clear />
                    <add name="AspNetSqlMembershipProvider"
                         type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                         connectionStringName="DGexEntities"
                         enablePasswordRetrieval="false"
                         enablePasswordReset="true"
                         requiresQuestionAndAnswer="false"
                         applicationName="DGex"
                         requiresUniqueEmail="false"
                         passwordFormat="Hashed"
                         maxInvalidPasswordAttempts="5"
                         minRequiredPasswordLength="1"
                         minRequiredNonalphanumericCharacters="0"
                         passwordAttemptWindow="10"
                         passwordStrengthRegularExpression=""/>
                </providers>
            </membership>
            <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
                <providers>
                    <clear/>
                    <add name="AspNetSqlRoleProvider" connectionStringName="DGexEntities" applicationName="DGex" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>                
                </providers>
            </roleManager>
        </system.web>

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ASP.NET Membership Role in Windows Application

    Aha.
    I think that is your problem.
    You will not supply the default asp provider but a custom one.
    P.E.
    Code:
    <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
                <providers>
                    <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString" applicationName="MyApplication" enablePasswordRetrieval="true" enablePasswordReset="true" ......etc/>
                </providers>
            </membership>
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: ASP.NET Membership Role in Windows Application

    yes, u are correct sapator

    after i changed the name, it not create app_bin folder anymore

    now i can sleep tight

    very thx for the help...

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  10. #10
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [RESOLVED]ASP.NET Membership Role in Windows Application

    No problem.
    Please mark the thread as resolved.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width