亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? authenticationmodule.cs

?? BugNET is an issue tracking and project issue management solution built using the ASP.NET web applic
?? CS
字號:
using System;
using System.Web;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;
using System.DirectoryServices;
using BugNET.BusinessLogicLayer;
using log4net;
using log4net.Config;

namespace BugNET.HttpModules
{
    /// <summary>
    /// BugNET Authentication HttpModule
    /// </summary>
    public class AuthenticationModule : IHttpModule
    {
        private static readonly ILog Log = LogManager.GetLogger(typeof(AuthenticationModule));
        private const string _filter = "(&(ObjectClass=Person)(SAMAccountName={0}))";
        private static string _path = String.Empty;

        /// <summary>
        /// Gets the name of the module.
        /// </summary>
        /// <value>The name of the module.</value>
        public string ModuleName
        {
            get { return "AuthenticationModule"; }
        }

        #region IHttpModule Members

        /// <summary>
        /// Disposes of the resources (other than memory) used by the module that implements <see cref="T:System.Web.IHttpModule"></see>.
        /// </summary>
        public void Dispose()
        {}

        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpApplication"></see> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application</param>
        public void Init(HttpApplication context)
        {
            context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
        }

        /// <summary>
        /// Handles the AuthenticateRequest event of the context control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        void context_AuthenticateRequest(object sender, EventArgs e)
        {

            // Start of changes by Stewart Moss
            // 18 Oct 2008 15:53
            //
            // Made changes to the conditions under which a new user account is created.
            // Refer to:
            // http://www.bugnetproject.com/Forums/tabid/54/forumid/9/threadid/1632
            //
            // Also improved the logging to ensure nobody is monkeying about without admin's permission.
            // Added assigning of auto roles as per 
            // http://bugnetproject.com/Forums/tabid/54/forumid/-1/threadid/1836/scope/posts/Default.aspx

            //get host settings
            bool enabled = HostSetting.GetHostSetting("UserAccountSource") == "ActiveDirectory" || HostSetting.GetHostSetting("UserAccountSource") == "WindowsSAM";

            //check if windows authentication is enabled in the host settings
            if (enabled)
            {
                // This was moved from outside "if enabled" to only happen when we need it.
                HttpRequest request = HttpContext.Current.Request;

               // not needed to be removed
               // HttpResponse response = HttpContext.Current.Response;

                if (request.IsAuthenticated)
                {
                    if ((request.LogonUserIdentity.AuthenticationType == "NTLM" || request.LogonUserIdentity.AuthenticationType == "Negotiate"))
                    {
                        //check if the user exists in the database 
                        MembershipUser user = ITUser.GetUser(HttpContext.Current.User.Identity.Name);

                        if (user == null)
                        {
                            try
                            {
                                UserProperties userprop = GetUserProperties(HttpContext.Current.User.Identity.Name);
                                //create a new user with the current identity and a random password.
                                ITUser.CreateUser(HttpContext.Current.User.Identity.Name, Membership.GeneratePassword(7, 2), userprop.Email);
                                user = ITUser.GetUser(HttpContext.Current.User.Identity.Name);
                            }
                            catch (Exception ex)
                            {
                                Log.Error(String.Format("Unable to add new user '{0}' to BugNET application. Authentication Type='{1}'.", HttpContext.Current.User.Identity.Name, request.LogonUserIdentity.AuthenticationType), ex);
                            }

                            try
                            {
                                //auto assign user to roles
                                List<Role> roles = Role.GetAllRoles();
                                foreach (Role r in roles)
                                {
                                    if (r.AutoAssign)
                                        Role.AddUserToRole(user.UserName, r.Id);
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(String.Format("Unable to auto assign roles to user '{0}'.", user.UserName), ex);
                            }

                        }
                        else
                        {
                            //update the user's last login date.
                            user.LastLoginDate = DateTime.Now;
                            Membership.UpdateUser(user);
                        }
                    }
                    else
                    {
                        // Warning:
                        // This line may generate too many log entries!!
                        // We will have to see in practice.
                        Log.Error(String.Format("Unknown Authentication Type '{0}'.", request.LogonUserIdentity.Name));
                    }
                }
                else 
                {
                    // if ! IsAuthenticated then log
                    Log.Error(String.Format("User '{0}' is not Authenticated.", request.LogonUserIdentity.Name));
                }
            }
            // End of changes by Stewart Moss
            // 18 Oct 2008
        }

        /// <summary>
        /// Gets the users properties from the specified user store.
        /// </summary>
        /// <param name="identification">The identification.</param>
        /// <returns>
        /// Class of user properties
        /// </returns>
        public UserProperties GetUserProperties(string identification)
        {
            UserProperties userprop = new UserProperties();
            userprop.FirstName = identification;
      
            // Determine which method to use to retrieve user information

            // WindowsSAM
            if (Globals.UserAccountSource == "WindowsSAM")
            {
                // Extract the machine or domain name and the user name from the
                // identification string
                string[] samPath = identification.Split(new char[] { '\\' });
                _path = String.Format("{0}{1}{3}", "WinNT://", HostSetting.GetHostSetting("ADPath"), samPath[0]);

                try
                {
                    // Find the user
                    DirectoryEntry entryRoot = new DirectoryEntry(_path);
                    DirectoryEntry userEntry = entryRoot.Children.Find(samPath[1], "user");
                    userprop.FirstName = userEntry.Properties["FullName"].Value.ToString();
                    return userprop;
                }
                catch
                {
                    return userprop;
                }
            }

            // Active Directory
            else if (Globals.UserAccountSource == "ActiveDirectory")
            {
                DirectoryEntry entry = new DirectoryEntry(String.Format("{0}{1}","GC://",HostSetting.GetHostSetting("ADPath")), HostSetting.GetHostSetting("ADUserName"), HostSetting.GetHostSetting("ADPassword"), AuthenticationTypes.Secure);

                // Setup the filter
                identification = identification.Substring(identification.LastIndexOf(@"\") + 1,
                    identification.Length - identification.LastIndexOf(@"\") - 1);
                string userNameFilter = string.Format(_filter, identification);

                // Get a Directory Searcher to the LDAPPath
                DirectorySearcher searcher = new DirectorySearcher(entry);
                if (searcher == null)
                {
                    return userprop;
                }

                // Add the propierties that need to be retrieved
                searcher.PropertiesToLoad.Add("givenName");
                searcher.PropertiesToLoad.Add("mail");
                searcher.PropertiesToLoad.Add("sn");

                // Set the filter for the search
                searcher.Filter = userNameFilter;


                try
                {
                    // Execute the search
                    SearchResult search = searcher.FindOne();

                    if (search != null)
                    {
                        userprop.FirstName = SearchResultProperty(search, "givenName"); //firstname
                        userprop.LastName = SearchResultProperty(search, "sn"); //lastname
                        userprop.Email =  SearchResultProperty(search, "mail"); //email address

                        //TODO: add new properties here to fill the profile.
                        return userprop;
                    }
                    else
                        return userprop;
                }
                catch
                {
                    return userprop;
                }
            }
            else
            {
                // The user has not choosen an UserAccountSource or UserAccountSource as None
                // Usernames will be displayed as "Domain/Username"
                return userprop;
            }
        }

        /// <summary>
        /// Searches the result property.
        /// </summary>
        /// <param name="sr">The sr.</param>
        /// <param name="field">The field.</param>
        /// <returns></returns>
        private static String SearchResultProperty(SearchResult sr, string field)
        {
            if (sr.Properties[field] != null)
            {
                return (String)sr.Properties[field][0];
            }

            return null;
        }

        #endregion

    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产91洋老外米糕| 国产露脸91国语对白| 亚洲国产精品一区二区尤物区| 亚洲一二三级电影| 丝袜美腿成人在线| 国模少妇一区二区三区| 国产 日韩 欧美大片| 不卡av电影在线播放| 欧美影视一区二区三区| 欧美日本国产一区| 久久精品人人爽人人爽| 最新高清无码专区| 奇米综合一区二区三区精品视频| 国产精品综合视频| 色天天综合色天天久久| 精品国产乱码久久久久久蜜臀| 日韩欧美在线影院| 自拍视频在线观看一区二区| 亚洲1区2区3区视频| 国产一区二区女| 大胆欧美人体老妇| 欧美猛男超大videosgay| 精品久久久久久久一区二区蜜臀| 亚洲一区二区三区影院| 91亚洲精品一区二区乱码| 中文一区在线播放| 国产馆精品极品| 国产网红主播福利一区二区| 国内外成人在线| 日韩午夜av一区| 日韩高清不卡一区二区| 欧美精品在欧美一区二区少妇| 一区二区日韩av| 欧美日韩精品专区| 午夜精品福利一区二区三区av | 成人99免费视频| 国产午夜精品久久久久久免费视| 国产伦精品一区二区三区免费迷| 色拍拍在线精品视频8848| 蜜桃视频在线一区| 日韩精品视频网| 欧美绝品在线观看成人午夜影视| 日韩欧美www| 九色综合狠狠综合久久| 日韩午夜激情视频| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 国产精品美女久久久久高潮| 欧美久久一二三四区| 波多野结衣在线一区| 蜜桃久久久久久久| 亚洲国产精品久久一线不卡| 日本一二三不卡| 26uuu久久天堂性欧美| 欧美曰成人黄网| 99精品黄色片免费大全| 国产在线观看免费一区| 丝袜诱惑亚洲看片| 亚洲人成在线播放网站岛国 | 51精品秘密在线观看| 97成人超碰视| 国产91精品一区二区麻豆亚洲| 免费的成人av| 午夜久久福利影院| 亚洲一区二区三区在线播放| 亚洲人精品一区| 亚洲三级免费电影| 最新欧美精品一区二区三区| 国产欧美日韩不卡| 久久久不卡网国产精品一区| 欧美哺乳videos| 精品欧美一区二区三区精品久久| 3atv一区二区三区| 欧美精品乱码久久久久久| 欧美三区在线观看| 欧美亚洲国产一区二区三区va | 国产成人av一区二区三区在线| 久久国产成人午夜av影院| 久久精品国产成人一区二区三区| 日本三级亚洲精品| 免费观看久久久4p| 另类小说视频一区二区| 久久精品国产网站| 精品一区二区三区免费视频| 精品一区二区三区视频在线观看 | 亚洲一卡二卡三卡四卡无卡久久 | 国产精品视频线看| 国产精品入口麻豆九色| 国产精品美女久久久久高潮| 亚洲欧美日韩在线播放| 亚洲激情在线激情| 亚洲成人在线免费| 奇米四色…亚洲| 国产麻豆成人传媒免费观看| 国产精品一区二区不卡| 懂色av一区二区三区蜜臀| 91免费在线视频观看| 欧美日韩免费一区二区三区| 欧美一区二区精美| 久久夜色精品国产噜噜av| 国产精品欧美经典| 亚洲一区二区三区小说| 日韩av不卡在线观看| 国产精品一线二线三线精华| www.99精品| 欧美日韩精品综合在线| 26uuu亚洲综合色| 亚洲美女淫视频| 日韩不卡免费视频| 国产成人精品影视| 色婷婷亚洲精品| 日韩精品在线网站| 国产精品美女一区二区| 亚洲一区精品在线| 国内精品伊人久久久久av影院| 成人av在线资源| 欧美老女人在线| 欧美国产激情二区三区| 亚洲资源中文字幕| 国产一区欧美一区| 欧美图片一区二区三区| 精品av综合导航| 亚洲综合视频在线观看| 久久精品理论片| 欧美曰成人黄网| 中文字幕乱码亚洲精品一区| 亚洲123区在线观看| 成人性生交大片免费看在线播放| 欧美日韩一区不卡| 国产精品久久久久毛片软件| 日韩精品五月天| 91麻豆精品在线观看| 欧美变态凌虐bdsm| 亚洲成人激情综合网| 国产成人免费视频网站高清观看视频| 欧美成人一级视频| 亚洲欧洲中文日韩久久av乱码| 另类小说图片综合网| 欧美日韩午夜在线视频| 中文在线资源观看网站视频免费不卡| 全部av―极品视觉盛宴亚洲| 色拍拍在线精品视频8848| 国产精品情趣视频| 激情深爱一区二区| 欧美日韩国产影片| 亚洲夂夂婷婷色拍ww47| 成人福利视频在线看| 精品国产露脸精彩对白| 日韩精品一卡二卡三卡四卡无卡| 91一区二区三区在线播放| 欧美极品美女视频| 黄页视频在线91| 日韩视频在线永久播放| 亚洲国产毛片aaaaa无费看| 99精品一区二区三区| 日本一区二区视频在线观看| 国产制服丝袜一区| 日韩丝袜情趣美女图片| 婷婷成人激情在线网| 欧美日韩在线播放三区| 一区二区三区加勒比av| 一本色道a无线码一区v| 最新国产の精品合集bt伙计| 波多野结衣亚洲一区| 国产精品国产成人国产三级| 国产成人在线电影| 中文字幕第一页久久| 国产精品羞羞答答xxdd| 26uuu亚洲综合色| 激情综合一区二区三区| 成人精品免费视频| 国产精品网站在线播放| 成人av网站在线观看免费| 亚洲国产精品传媒在线观看| 成人开心网精品视频| 中文字幕久久午夜不卡| 北岛玲一区二区三区四区| 中文字幕一区在线观看视频| 99这里只有精品| 亚洲男同1069视频| 欧美三级在线看| 蜜臀av亚洲一区中文字幕| 精品久久免费看| 岛国精品一区二区| 综合久久国产九一剧情麻豆| 99国产精品99久久久久久| 一区二区三区四区精品在线视频| 欧美亚洲一区三区| 日韩高清在线不卡| 久久午夜色播影院免费高清| 成人免费视频播放| 一区二区高清视频在线观看| 欧美日韩在线亚洲一区蜜芽| 蜜臀av一级做a爰片久久| 久久午夜国产精品| 91亚洲男人天堂| 日本视频一区二区三区| 国产免费成人在线视频| 日本精品免费观看高清观看| 免费在线观看日韩欧美| 国产日产欧美一区二区视频|