protected void Button1_Click(object sender, EventArgs e)
 {
     NetSqlAzMan.Providers.NetSqlAzManRoleProvider p = new NetSqlAzMan.Providers.NetSqlAzManRoleProvider();
     System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection();
     nvc.Add("connectionStringName", "NetSqlAzManConnectionString");
     nvc.Add("storeName", "Store Stress Test");
     nvc.Add("applicationName","Application0");
     nvc.Add("userLookupType", "LDAP");
     nvc.Add("defaultDomain", "EIDOS");
     p.Initialize("NetSqlAzManRoleProvider", nvc);
     //p.AddUsersToRoles(
     //    new string[] { "EIDOS\\A.ferendeles", "EIDOSIS4-AFR\\Administrator" } ,
     //    new string[] { "Role1", "Role2" });
     string s = p.ApplicationName;
     p.CreateRole("Ruolo di Prova");
     p.DeleteRole("Ruolo di prova", true);
     s = p.Description;
     //string[] roles = p.FindUsersInRole("Role0", "eidos\\a.ferendeles"); //NOT IMPLEMENTED
     string[] roles = p.GetAllRoles();
     roles = p.GetRolesForUser("EIDOS\\a.ferendeles");
     roles = p.GetRolesForUser("a.ferendeles");
     roles = p.GetRolesForUser("EIDOSIS4-AFR\\Administrator");
     string[] users = p.GetUsersInRole("Role5");
     bool isInRole = p.IsUserInRole("a.ferendeles", "Role9");
     p.RemoveUsersFromRoles(
         new string[] { "A.ferendeles", "EIDOSIS4-AFR\\Administrator" } ,
         new string[] { "Role1", "Role2" });
     bool roleExists = p.RoleExists("saaa");
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        NetSqlAzMan.Providers.NetSqlAzManRoleProvider      p   = new NetSqlAzMan.Providers.NetSqlAzManRoleProvider();
        System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection();
        nvc.Add("connectionStringName", "NetSqlAzManConnectionString");
        nvc.Add("storeName", "Store Stress Test");
        nvc.Add("applicationName", "Application0");
        nvc.Add("userLookupType", "LDAP");
        nvc.Add("defaultDomain", "EIDOS");
        p.Initialize("NetSqlAzManRoleProvider", nvc);
        //p.AddUsersToRoles(
        //    new string[] { "EIDOS\\A.ferendeles", "EIDOSIS4-AFR\\Administrator" } ,
        //    new string[] { "Role1", "Role2" });
        string s = p.ApplicationName;

        p.CreateRole("Ruolo di Prova");
        p.DeleteRole("Ruolo di prova", true);
        s = p.Description;
        //string[] roles = p.FindUsersInRole("Role0", "eidos\\a.ferendeles"); //NOT IMPLEMENTED
        string[] roles = p.GetAllRoles();
        roles = p.GetRolesForUser("EIDOS\\a.ferendeles");
        roles = p.GetRolesForUser("a.ferendeles");
        roles = p.GetRolesForUser("EIDOSIS4-AFR\\Administrator");
        string[] users    = p.GetUsersInRole("Role5");
        bool     isInRole = p.IsUserInRole("a.ferendeles", "Role9");

        p.RemoveUsersFromRoles(
            new string[] { "A.ferendeles", "EIDOSIS4-AFR\\Administrator" },
            new string[] { "Role1", "Role2" });
        bool roleExists = p.RoleExists("saaa");
    }
Exemple #3
0
 public UserAccountService(IUnitOfWork unitOfWork, IAzManStorage store, NetSqlAzManRoleProvider provider)
 {
     this._unitOfWork = unitOfWork;
     this._store = store;
     this._provider = provider;
 }
        public bool RemoveRole(string user, string application, string role)
        {
            //_provider.Initialize("AuthorizationRoleProvider", ConfigureAuthorizationRoleProvider("CATS", ""));
            //var provider = ((NetSqlAzMan.Providers.NetSqlAzManRoleProvider)Roles.Provider);
            var provider = new NetSqlAzManRoleProvider();
            provider.Initialize("RoleProvider", ConfigureAuthorizationRoleProvider("CATS",""));
            var users = new string[] { user };
            var userRoles = new string[] { role };

            provider.ApplicationName = application;
            provider.RemoveUsersFromRoles(users, userRoles);

            //const string store = "CATS";

            //string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["CatsContext"].ConnectionString;
            //IAzManStorage storage = new SqlAzManStorage(connectionString);
            //IAzManStore mystore = storage.GetStore("CATS"); //or storage["My Store"]
            //IAzManApplication myapp = mystore.GetApplication(application);

            //IAzManItem azManRole = myapp.GetItem(role);
            //try
            //{
            //    azManRole.DeleteDelegateAuthorization(
            //                                         mystore.GetDBUser(user),
            //                                         mystore.GetDBUser("Admin").CustomSid,
            //                                         RestrictedAuthorizationType.Allow
            //                                     );
            //}
            //catch(Exception ex)
            //{

            //}

            //azManRole.DeleteDelegateAuthorization();
            //azManRole.DeleteDelegateAuthorization();

            return true;
        }