More in this section

Forums / Developing with Sitefinity / sitefinity membership

sitefinity membership

2 posts, 0 answered
  1. developer
    developer avatar
    13 posts
    Registered:
    11 Feb 2013
    14 Feb 2013
    Link to this post

    I create some users and set them role in sitefinity. I writed a login usercontrol. I'd like to validate password and username in code behind. How to do this? can you give me some c# example code?

  2. Dave
    Dave avatar
    22 posts
    Registered:
    05 Nov 2012
    14 Feb 2013
    Link to this post

    Hi, 

    I went off of the blog post by the falafel folks. http://blog.falafel.com/blogs/noelrice/noel-rice/2012/03/28/using-sitefinity-5-claims-authentication

    Here's the fsharp code I use to access the authentication service

    module main
    open System.Net
     
    let credentialsFormat =  @"
            {{
                ""MembershipProvider"":""{0}"",
                ""Password"":""{1}"",
                ""Persistent"":{2},
                ""UserName"":""{3}""
            }}"
     
    let json = System.String.Format(credentialsFormat, "Default", "password", true ,"user")
    let credentials = System.Text.Encoding.UTF8.GetBytes(json)
    let webRequest = HttpWebRequest.Create(@"http:/<siteurl>/Sitefinity//Sitefinity/Services/Security/Users.svc/Authenticate");
    webRequest.Method <- "Post"
    webRequest.ContentType <- "application/json"
    webRequest.ContentLength <- int64(credentials.Length)
     
     
    [<EntryPoint>]
    let main argv =
        let reqStream = webRequest.GetRequestStream().Write(credentials,0,credentials.Length)
        use response = webRequest.GetResponse() :?> HttpWebResponse
        let stream = response.GetResponseStream();
        printfn "%A" stream

        printfn "%A" argv

    I'm not super great at sitefinity so someone may have a better answer for you. 

    Dave

2 posts, 0 answered