Reconstruct ProviderUserKey from AzManSid

Mar 24, 2010 at 3:45 PM

I have hit an issue.  I am trying to relink the database user to the authorized user, all I have to link them is the AzMan SID and the membership users ProviderUserKey and these don't match at all.  So I do really need a method of regenerating the original ProviderUserKey from the Authorization SID.  Is this possible?

 The code I am using to get the Membership users is as follows:

            List searchResults = new List();
            MembershipUserCollection DBUserList = Membership.FindUsersByName("%" + searchText + "%");

            foreach (MembershipUser user in DBUserList)
                searchResults.Add(user.UserName + "|" + user.ProviderUserKey.ToString());

            return searchResults;

 The ProviderUserKey is the only thing I have in order to relink the search results to the assigned Authorization DB User as I have a requirement to show the existing state of the user that is within AzMan within the search result set..

Mar 24, 2010 at 5:30 PM


I’m a little bit confused about your quuestion.

NetSqlAzManRoleProvider is a Role Provider and not a MemberShipProvider.

So, you should use something like this in the web.config file:


            <roleManager defaultProvider="NetSqlAzManRoleProvider" enabled="true" cacheRolesInCookie="false" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">



        <remove name="AspNetSqlMembershipProvider"/>

        <add name="NetSqlAzManRoleProvider" type="NetSqlAzMan.Providers.NetSqlAzManRoleProvider" connectionStringName="NetSqlAzManConnectionString" storeName="Eidos" applicationName="DB Persone" userLookupType="DB" defaultDomain=""/>



And something like this to retrieve Users in Role:

string[] users = Roles.GetUsersInRole("My Role");

Why you are using code like:

 MembershipUserCollection DBUserList = Membership.FindUsersByName("%" + searchText + "%");

This is about … MemberShipProvider and not Role Provider.

Please let me know.



Andrea Ferendeles
NetSqlAzMan Project Coordinator  
E-mail Web

Mar 25, 2010 at 8:44 AM


Yeah it sounded weird when I re-read what I had put too, I should of been using the GetDBUser method in NetSqlAzMan and not the Membership ones, I have changed it and its now working :-).  I take it you only need to add the above to your web.config if you are working with the NetSqlAzMan user tables etc.  I have my solution working with the ASPNET membership tables as the application I am developing against used mixed mode authentication.

Mar 25, 2010 at 9:56 AM