0

我将 Dotnetopenid 用于我的 openid 解决方案,使用内置用户控件时一切都很好,但是当我想以编程方式实现它时,如下面的代码,

openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();

始终为空。任何的想法?

    OpenIdRelyingParty openid = createRelyingParty();
    if (openid.Response != null) {
        switch (openid.Response.Status) {
            case AuthenticationStatus.Authenticated:
                // This is where you would look for any OpenID extension responses included
                // in the authentication assertion.
                // var extension = openid.Response.GetExtension<SomeExtensionResponseType>();

                // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
                // with the OpenID Claimed Identifier as their username.
                State.ProfileFields = openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();
                FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
                break;
4

2 回答 2

3

从安德鲁那里得到帮助

在重定向到提供者之前,我错过了为我的请求添加扩展名。(此步骤未在示例文件中编码)

为此,在创建请求对象后执行以下操作:

  Dim request As IAuthenticationRequest = openid.CreateRequest(openid_identifier.Text)
        ' This is where you would add any OpenID extensions you wanted
        ' to include in the authentication request.
        ' request.AddExtension(someExtensionRequestInstance);
        Dim myclaim As New ClaimsRequest

        With myclaim
            .BirthDate = DemandLevel.Request
            .Country = DemandLevel.Request
            .Email = DemandLevel.Request
            .FullName = DemandLevel.Request
            .Gender = DemandLevel.Request
            .Language = DemandLevel.Request
            .Nickname = DemandLevel.Request
            .PostalCode = DemandLevel.Request
            .TimeZone = DemandLevel.Request

        End With


        request.AddExtension(myclaim)









        ' Send your visitor to their Provider for authentication.
        request.RedirectToProvider()

代码在 vb.net

于 2009-03-08T18:13:08.330 回答
0

注意在下一个版本中修复并更清晰。

于 2009-03-09T22:16:13.353 回答