我就是iHqq

掬水月在手,弄花香满衣

My Links

Blog Stats

News

2010年1月5日 #

在Identity 增加自己的属性 部门,并且使用access mdb文件实现角色验证

代码
using System;
using System.Collections;
using System.Data.OleDb;

/****************************************************************************

 * 函数使用说明 
 * 一、首先在使用web.config中设置 数据库连接字符串 mdb文件
 *   <connectionStrings>
    <add name="Main" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source='D:\Backup\我的文档\Visual Studio 2008\WebSites\WebSite2\App_Data\data.mdb'"/>
  </connectionStrings>
 * 二、在代码中加入引用 using MyUserLoginClass;
 * 三、在  protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)中书写代码
          {
            Login m_Login = (Login)sender;
            MyPrincipal principal = new MyPrincipal(m_Login.UserName, m_Login.Password);

            if(principal.Identity.IsAuthenticated)
            {
                // 如果用户通过验证,则生成用户验证票 
                Context.User = principal;

                MyIdentity myid= (MyIdentity)(Context.User.Identity);
                
                Label1.Text = myid.Department;

                System.Web.Security.FormsAuthentication.SetAuthCookie(m_Login.UserName, true);

                e.Authenticated = true;


                return;
            }
            else
            {
                m_Login.FailureText = "用户名或密码错误";
                e.Authenticated = false;
                return;
            }

*****************************************************************************
*/

namespace MyUserLoginClass

     
/// <summary> 
     
/// MyPrincipal 的摘要说明。 
     
/// </summary> 
     
/// 实现IPrincipal接口 
     public class MyPrincipal : System.Security.Principal.IPrincipal 
     {
         
private MyIdentity identity; 

        
private ArrayList roleList;        

        
public MyPrincipal(string UserName,string Password) 
        { 
           
// 
           
// TODO: 在此处添加构造函数逻辑 
           
// 
           identity = new MyIdentity(UserName,Password);

           
if (identity.IsAuthenticated)
           {
               roleList 
= new ArrayList();
               roleList 
= identity.RoleList;
           }             
        } 
         
        
public ArrayList RoleList 
        { 
           
get 
           { 
              
return roleList; 
           } 
        } 
        
#region IPrincipal 成员 

        
public System.Security.Principal.IIdentity Identity 
        { 
           
get 
           { 
              
// TODO:    添加 MyPrincipal.Identity getter 实现 
              return identity; 
           } 
           
set 
           { 
              identity 
= (MyIdentity)value; 
           } 
        } 

        
public bool IsInRole(string role) 
        { 
           
// TODO:    添加 MyPrincipal.IsInRole 实现 
           return roleList.Contains(role); 
        } 

        
#endregion 
     }
     
public class MyIdentity : System.Security.Principal.IIdentity
     {
         
private string m_UserName;
         
private string m_Password;
         
private string m_AuthenticationType;
         
private string m_Department;
         
private string m_Role;
         
private ArrayList roleList;

         
public MyIdentity(string UserName, string Password)
         {
             
// 
             
// TODO: 在此处添加构造函数逻辑 
             
// 
             m_UserName = UserName;
             m_Password 
= Password;   
         }
       
         
//验证 是否有效用户
         private bool CanPass()
         {
             
//这里朋友们可以根据自己的需要改为从数据库中验证用户名和密码, 
             
//这里为了方便我直接指定的字符串 
             bool bPass = false;

             
using (OleDbConnection conn = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Main"].ConnectionString))
             {
                 OleDbCommand cmd 
= new OleDbCommand("SELECT * FROM 用户表 WHERE ((用户名=@UserName) AND (密码=@Password))", conn);
                 cmd.Parameters.AddWithValue(
"UserName", m_UserName);
                 cmd.Parameters.AddWithValue(
"Password", m_Password);
                 
try
                 {
                     conn.Open();

                     OleDbDataReader dr 
= cmd.ExecuteReader();

                     
if (dr.Read()) 
                     {
                         roleList 
= new ArrayList();

                         m_Department 
= dr["部门"].ToString();

                         m_Role 
= dr["角色"].ToString();

                         
string[] strRole = m_Role.Split(';');

                         
foreach (string s in strRole)
                         {
                             roleList.Add(s);
                         }
                         bPass 
= true
                     }
                     
else { bPass = false; }

                     dr.Close();

                     conn.Close();
                 }
                 
catch (Exception ex)
                 {

                 }
             }
             
return bPass;
         }         
         
public string Department
         {
             
get
             {
                 
return m_Department;
             }
         }
         
public string Password
         {
             
get
             {
                 
return m_UserName;
             }
             
set
             {
                 m_UserName 
= value;
             }
         }
         
         
public bool IsAuthenticated
         {
             
get
             {
                 
// TODO:    添加 MyIdentity.IsAuthenticated getter 实现 
                 return CanPass();
             }
         }
         
public ArrayList RoleList
         {
             
get
             {
                 
return roleList;
             }
         } 

         
public string Name
         {
             
get
             {
                 
// TODO:    添加 MyIdentity.Name getter 实现 
                 return m_UserName;
             }
             
set
             {
                 m_UserName 
= value;
             }
         }

         
public string AuthenticationType
         {
             
get
             {
                 
// TODO:    添加 MyIdentity.AuthenticationType getter 实现 
                 return m_AuthenticationType;
             }
             
set
             {
                 m_AuthenticationType 
= value;
             }
         }
     } 

 

posted @ 2010-01-05 17:44 iHqq 阅读(78) 评论(0) 编辑

2009年2月6日 #

vodafone 1210 上网问题

原始使用的dopod 575第一款智能手机!爱机不能忍受我的残酷剥削,前期终于为事业献身了。

从淘宝买了一款vodafone 1210,很不错,拿到机器后发现上网功能不行,硬启之后使用恢复gprs上网设置

也是无法正常上网,从网上查询得知:说是无线模块版本太低,必须刷机完成后第一时间恢复gprs设置

硬启应该就相当于刷机之后第一次启动吧,第一时间恢复gprs设置,问题照旧。

难不成真的要重新刷机刷成高版本的无线模块。

我的解决方法:

硬启之后我不用软件恢复gprs设置,我自己手动来设置,设置内容就很简单了,cmnet cmwap 10.0.0.172:9201

具体参数和其他智能机是一样的!

结论:不是无线版本太低的原因,是因为设置恢复的时候出现了问题。

而后在网上找到了新的解决办法(我没有尝试)

.再次重申GPRS问题,刷完机后,不需要硬启,只要在进系统后第一时间进入设置->连接->恢复GPRS默认设置,然后进入GPRS,删除用不上的接入点,如果是联通请新增一个UNIWAP的接入点,然后用IE上下网,就OK了!!如果用CMWAP的话,只用在开机后让UCWEB6.1BATE设置下网络,也可以上网了。
如果还是不能上网,请将[HKEY_LOCAL_MACHINE\Comm\Cellular\RIL]下的两个键值删除,然后重启一下,再进行设置,应该就可以上网了!

posted @ 2009-02-06 10:56 iHqq 阅读(234) 评论(0) 编辑

2008年12月13日 #

WTL 8.0 在VC 2008 下使用问题

posted @ 2008-12-13 16:54 iHqq 阅读(569) 评论(0) 编辑

2008年8月4日 #

关于解决插入USB设备蓝屏的思路【转】

近日在作维修服务时发现不少用户存在一个问题就是很多电脑在插入部分USB设备时电脑会立刻蓝屏,首先我尝试了卸载了设备管理器里的所有关于USB的项目,然后重启后测试,结果发现在系统自动检测USB设备时再次立刻蓝屏,无法只能试着卸载删除所有的USB驱动文件,最终问题才得已解决,方法如下:
1、进入C:>windows>system32>drives下删掉USBehci.sys usbhub.sys   usbohci.sys usbport.sys
2、进入设备管理器,拆毁所有的USB驱动,
3、进入C:>windows>system32下删掉usbui.dll
重新启动计算机!

注:出现此类问题的客户大多安装的是GHOST版本的系统,如果接照上述方法未能得到解决,很可能是这个驱动和显卡的驱动有冲突所致,建议卸载掉显卡的驱动以及按照上述方法卸载掉USB驱动.

也可以尝试直接下载附件中文件直接按附件中的说明直接覆盖掉原文件即可:

http://option.cicconline.com/

posted @ 2008-08-04 08:33 iHqq 阅读(2103) 评论(1) 编辑

2007年11月7日 #

zt上海相亲 遭遇势利贪婪80后女孩

摘要: 认识司爽是由于我以前所采访的一位单身男人,邀请我参加的一次聚会,那次聚会实际上是一次相亲的安排,也是一次我所见过的阵容最强大,场面最严肃的类似谈判似的相亲见面会。

  见面会安排在上海浦东金茂大厦的88层咖啡厅,那里的咖啡一杯就要88元,我的那位朋友事业小成,还算有点儿身家,就是这些年忙于创业30几岁了还孑然一身,这次如此隆重地安排相亲,看来是对这位未曾谋面的上海女孩动了凡心。

  不过他很快就领略到想娶一个上海女孩所要经历的考验了。

  那天晚上女主角司爽和她的家人晚到了一个半小时,朋友接到她们一家莅临金葳大厦的电话后就站到电梯门口翘首以待,可从电梯里走下老老少少大概有七、八个人之多,就是不见相亲的女主角司爽,朋友有点儿急,忙问一个年龄稍长,一脸精明的女人,被告知女孩正在化妆间,一会儿再上来。等把所有的人都安排到座位上,88元的咖啡人手一杯地开始轻烟缭绕以后,女孩司爽娉娉婷婷地在妈妈的陪伴下走出电梯。

  女孩的皮肤很好,细瓷般闪着光,眉眼清秀,打扮时尚,是个典型的上海小家碧玉。朋友一看眼睛就有点儿发亮,阅读全文

posted @ 2007-11-07 12:36 iHqq 阅读(202) 评论(3) 编辑

2007年9月23日 #

整合网络中的VC2005中manifest问题

posted @ 2007-09-23 18:06 iHqq 阅读(1219) 评论(0) 编辑

2007年8月5日 #

smartphone 下读取快捷方式 (2)

摘要: SHGetShortcutTarget 快捷方式 读取阅读全文

posted @ 2007-08-05 19:31 iHqq 阅读(248) 评论(0) 编辑

smartphone 创建快捷方式 shorcut(1)

摘要: SHCreateShortCut 快捷方式 smartphone evc 阅读全文

posted @ 2007-08-05 19:26 iHqq 阅读(258) 评论(0) 编辑

Evc 4.0 调试宏

posted @ 2007-08-05 11:11 iHqq 阅读(111) 评论(0) 编辑

2007年3月26日 #

定位输入点XXXX 在msdart.dll 上错误(最终版)

摘要: 打开Outlook 2003或者 带数据库的程序时,提示无法定为输入点 XXX在msdart.dll,在网上查了查需要重新安装 MDAC_TYP2.8/ 阅读全文

posted @ 2007-03-26 22:50 iHqq 阅读(3455) 评论(4) 编辑

仅列出标题  下一页