Windows authentication or user login needed

Last post 11-15-2007, 2:31 PM by Adam. 10 replies.
Sort Posts: Previous Next
  •  11-09-2007, 11:08 AM 34936

    Windows authentication or user login needed

    Hi,  I looking for a solution to get users authenticated via their windows login info.
    I need to get the username if it is an authenticated windows user and if this info is not available then get login via the normal login page. 
    In VB I only know to do get logon things via this code:
    LogonVariable = UCase(Request.ServerVariables("LOGON_USER"))
     
    How would I be able to change Cute Chat so that it would grab the windows login info if available ?
    And then thensecond part, if this is not available, get users to the login page ?
     
    Many thanks!
    Filed under:
  •  11-09-2007, 9:51 PM 34947 in reply to 34936

    Re: Windows authentication or user login needed

    in the integration code , you can do something like :
     
    public override AppChatIdentity GetLogonIdentity()
    {
      string name=HttpContext.Current.Request.ServerVariables["LOGON_USER"];
      if(name==null||name=="")return null;
      return new AppChatIdentity(name,false,ToUserId(name),HttpContext.Current.Request.UserHostAddress);
    }
     
    and you also need to return some information for the function :
     
    public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
    {
        //change this code to better
        nickName=loginName;
        isAdmin=false;
        return true;
    }
     
    Regards , Terry.
     
  •  11-12-2007, 2:44 PM 35012 in reply to 34947

    Re: Windows authentication or user login needed

    Would it be possible to get a a complete generic file with this code added. I don't know squat about asp.net. Nice upgrade by the way.
  •  11-13-2007, 10:46 AM 35031 in reply to 35012

    Re: Windows authentication or user login needed

    You can try this  Global.asax :
     

    <%@ Application Language="C#" %>
    <%@ Import Namespace="CuteChat" %>

    <script runat="server">

     void Application_Start(object sender, EventArgs e) {

            ChatProvider.Instance = new AspNetChatProvider();
            ChatSystem.Start(new AppSystem());
           
     }

        public class AspNetChatProvider : ChatProvider
        {
            public override string GetConnectionString()
            {
                return System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
            }

            public override AppChatIdentity GetLogonIdentity()
            {
                string fullname=HttpContext.Current.Request.ServerVariables["LOGON_USER"];
                if (fullname == null || fullname == "")
                    return null;

                string nickname = fullname.Split('\\')[1];

                return new AppChatIdentity(nickname, false, ToUserId(nickname), HttpContext.Current.Request.UserHostAddress);
            }
           
            public override string  FindUserLoginName(string nickName)
            {
                return nickName;
            }
            public override bool  GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
            {
                if (loginName == null || loginName == "")
                    return false;

                try
                {
                    System.Security.Principal.SecurityIdentifier sid = (System.Security.Principal.SecurityIdentifier)new System.Security.Principal.NTAccount(loginName).Translate(typeof(System.Security.Principal.SecurityIdentifier));
                }
                catch
                {
                    return false;
                }

                nickName = loginName;

                if (nickName == "Administrator")
                {
                    isAdmin = true;
                }
               
                return true;
            }

            public override bool ValidateUser(string username, string password)
            {
                return false;
            }
        }

       
    </script>

  •  11-13-2007, 11:36 AM 35034 in reply to 35031

    Re: Windows authentication or user login needed

    Thanks...I will give it a try. I greatly appreciate the effort.
  •  11-13-2007, 12:36 PM 35036 in reply to 35034

    Re: Windows authentication or user login needed

    Thanks but no joy, receiving client chat errors.
  •  11-13-2007, 2:12 PM 35037 in reply to 35036

    Re: Windows authentication or user login needed

    sstepanski:
    Thanks but no joy, receiving client chat errors.
     
    Error message?
     
    Can you download the latest build and try again?
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-15-2007, 6:57 AM 35097 in reply to 35037

    Re: Windows authentication or user login needed

    I have tried both the snipet of code and the example global.asax and I get these same two error no matter what I do. Any thioughts?
     
     
     
     
  •  11-15-2007, 1:38 PM 35119 in reply to 35097

    Re: Windows authentication or user login needed

  •  11-15-2007, 2:26 PM 35125 in reply to 35119

    Re: Windows authentication or user login needed

    Downloaded app again, replace web folder, added code to global.asax....same error. It may have a lot to do with the fact that I don't know what I'm doing but I'm not sure.
  •  11-15-2007, 2:31 PM 35126 in reply to 35125

    Re: Windows authentication or user login needed

View as RSS news feed in XML