webForumDet fria alternativet

WebConfigurationManager

0 svar · 350 visningar · startad av Arne

ArneMedlem sedan maj 2000267 inlägg
#1

Vill lägga till och radera användare i web.config via codebehind och har kommit så pass att jag kan lägga till användare. Men jag får det icke att fungera att radera en användare.

        Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~", Nothing, "admin", "")
        Dim section As AuthorizationSection = CType(config.GetSection("system.web/authorization"), AuthorizationSection)
        Dim rule As New AuthorizationRule(AuthorizationRuleAction.Allow)

        If e.Checked Then
            rule.Users.Add(e.Item("medlemsnr"))
            section.Rules.Add(rule)
        Else
            'detta fungerar ej.....
            rule.Users.Remove(e.Item("medlemsnr"))
            section.Rules.Remove(rule)
        End If

        config.Save()

Jag vill alltså radera t.ex användaren 10112 i web.config <allow users="10112 " />:

127 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)