技术笔记:MOSS&SSO系列1

简介: 技术笔记:MOSS&SSO系列1

最近写了几个SSO的WebParts,发现了些问题,于是提出共参:


Step1: 引用相关的DLL


using Microsoft.SharePoint.Portal.SingleSignon;


using Microsoft.SharePoint.Portal;


或者你可以直接这么做:编辑当前项目的Web.config的


加入:


Step2: 配置MOSS上的SSO


(简单,暂且不表)注意多半要在数据库登录帐户中添加:NT AUTHORITY\ANONYMOUS LOGON 给个可以创建数据库和管理权限的即可!


Step3:Coding...


2种写法都可以,暂不明白?


写法1 string strSSOLogonFormUrl = SingleSignonLocator.GetCredentialEntryUrl("DEMOSSO");


string【】 rgGetCredentialData = null;


Credentials.GetCredentials(1, "DEMOSSO", ref rgGetCredentialData);


string strName = rgGetCredentialData【0】;


string strPwd = rgGetCredentialData【1】;


......


写法2 IntPtr pUserName = IntPtr.Zero;


IntPtr pPassword = IntPtr.Zero;


ISsoProvider isso = SsoProviderFactory.GetSsoProvider();


SsoCredentials myCreds = isso.GetCredentials("DEMOSSO");


pUserName = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(myCreds.UserName);


pPassword = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(myCreds.Password);


string uName = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(pUserName);


string uPwd = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(pPassword);


END:


catch (SingleSignonException ssoe)


{


if (SSOReturnCodes.SSO_E_CREDS_NOT_FOUND == ssoe.LastErrorCode)


{


Context.Response.Redirect(strSSOLogonFormUrl);


}


else


{


Response.Redirect(strSSOLogonFormUrl);


}


}


Step4:读Exchange Server 2007 的新邮件


引用WebServices先:ICredentials creds = new NetworkCredential(userNaem, rgGetCredentialData【1】, "demo");


// ICredentials creds = CredentialCache.DefaultNetworkCredentials;//("mailadmin", "Pass!word", "demo")


exchangeServer.Credentials = creds;


exchangeServer.Url = @"";


DistinguishedFolderIdType【】 folderIDArray = new DistinguishedFolderIdType【1】;


folderIDArray【0】 = new DistinguishedFolderIdType();


folderIDArray【0】.Id = DistinguishedFolderIdNameType.inbox;


PathToUnindexedFieldType ptuftDisplayName = new PathToUnindexedFieldType();


ptuftDisplayName.FieldURI = UnindexedFieldURIType.folderDisplayName;


PathToExtendedFieldType pteftComment = new PathToExtendedFieldType();


pteftComment.PropertyTag = "0x3004"; // PR_COMMENT


pteftComment.PropertyType = MapiPropertyTypeType.String;


GetFolderType myfoldertype = new GetFolderType();


myfoldertype.FolderIds = folderIDArray;


myfoldertype.FolderShape = new FolderResponseShapeType();


myfoldertype.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;


myfoldertype.FolderShape.AdditionalProperties = new BasePathToElementType【2】;


myfoldertype.FolderShape.AdditionalProperties【0】 = ptuftDisplayName;


myfoldertype.FolderShape.AdditionalProperties【1】 = pteftComment;


GetFolderResponseType myFolder = exchangeServer.GetFolder(myfoldertype);


FolderInfoResponseMessageType firmtInbox =


(FolderInfoResponseMessageType)myFolder.ResponseMessages.Items【0】;


PathToUnindexedFieldType ptuftSubject = new PathToUnindexedFieldType();


ptuftSubject.FieldURI = UnindexedFieldURIType.itemSubject;


PathToUnindexedFieldType ptuftBody = new PathToUnindexedFieldType();


ptuftBody.FieldURI = UnindexedFieldURIType.itemAttachments;


PathToExtendedFieldType pteftFlagStatus = new PathToExtendedFieldType();


pteftFlagStatus.PropertyTag = "0x1090"; // PR_FLAG_STATUS


pteftFlagStatus.PropertyType = MapiPropertyTypeType.Integer;


FindItemType findItemRequest = new FindItemType();


findItemRequest.Traversal = ItemQueryTraversalType.Shallow;


findItemRequest.ItemShape = new ItemResponseShapeType();


findItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.Default;


findItemRequest.ParentFolderIds = new FolderIdType【1】;


findItemRequest.ParentFolderIds【0】 = firmtInbox.Folders【0】.FolderId;


FindItemResponseType firt = exchangeServer.FindItem(findItemRequest);


MessageType mt = //代码效果参考:http://www.jhylw.com.cn/471541537.html

new MessageType();

int newEmail = 0;//Unread email number


int totalEmail = 0;//Total Email number


foreach (FindItemResponseMessageType firmtMessage in firt.ResponseMessages.Items)


{


if (firmtMessage.RootFolder.TotalItemsInView > 0)


{


totalEmail = firmtMessage.RootFolder.TotalItemsInView;


foreach (ItemType it in ((ArrayOfRealItemsType)firmtMessage.RootFolder.Item).Items)


{


//代码效果参考:http://www.jhylw.com.cn/495823269.html

mt = it as MessageType;

if (mt != null)


{


//this.TextBox1.Text += string.Format(string.Format("是否已读: {0}


", mt.IsRead.ToString()));


if (!mt.IsRead)


newEmail++;


else


continue;


}


#region Eg codes


//Response.Write(string.Format("


标题: {0}


", it.Subject));


//Response.Write(string.Format("


标题: {0}


", it.Subject)+string.Format("发件人: {0}


", mt.IsRead.ToString()));


//Response.Write(string.Format("收件人: {0}


", it.DisplayTo));


//Response.Write(string.Format("抄送人: {0}


", it.DisplayCc));


//Response.Write(string.Format("大小: {0}


", it.Size.ToString()));


//Response.Write(string.Format("


标题: {0}


", it.Subject)+string.Format("发件人: {0}


", mt.IsRead.ToString())+string.Format("重要性: {0}


", it.Importance.ToString()));


////Response.Write(string.Format("是否已读: {0}


", ((MessageType)(it)).IsRead.ToString()));


////Response.Write(string.Format("是否已读: {0}


", it.is));


//Response.Write(string.Format("附件: {0}


", it.HasAttachments.ToString()));


//Response.Write(string.Format("接收时间: {0}


", it.DateTimeReceived.ToString()));


//if (it.Body != null)


//{


// Response.Write(string.Format("正文: {0}


", it.Body.Value));


//}


//if (null != it.ExtendedProperty)


//{


// Response.Write(string.Format("Prop 0x1090: {0}\n\n", it.ExtendedProperty【0】.Item.ToString()));


//}


//else


//{


// Response.Write(string.Format("Prop 0x1090: not found"));


//}


#endregion


}


}


}


Response.Write(newEmail.ToString() + "//" + totalEmail.ToString());


Step5:AJAX更新结果


基本的例子,总邮件数顺便也可以拿到的。。。


下回谈谈如何与OWA集成起来!


EOF


本文链接:


关于博主:评论和私信会在第一时间回复。或者直接私信我。


版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!


声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!


msn: pccai1983@hotmail.com

相关文章
|
3月前
|
自然语言处理 算法 测试技术
大模型评测 Benchmark:关键指标与选型方法
大模型评测 Benchmark 是用数据集和评测维度量化模型能力的方法。本文梳理推理结果打分、吞吐量、延迟与 token 级指标,帮助研发和业务团队完成模型对比与选型。
730 0
|
4月前
|
缓存 人工智能 监控
Qwen3.8-Max 深度使用实战:从 2.4 万亿参数到生产级智能体落地
Qwen3.8-Max 是阿里云通义千问 2026 年 8 月最新发布的旗舰基座模型,2.4 万亿参数 MoE 架构、1M 上下文窗口、原生多模态(文本+图像+视频),具备"自主编程十数天交付完整项目"的长程闭环能力。本文不是又一篇"怎么调 API"的入门教程,而是一线团队将 Qwen3.8-Max 从 PoC 推向生产的深度实践记录:百炼平台开通与 API Key 管理、OpenAI 兼容协议接入、多模态与 Function Calling 进阶、思考模式与上下文缓存调优、Token Plan 订阅选型、生产环境避坑实录。
|
3月前
|
人工智能 监控 安全
瓴羊 AgentOne 深度解析:四大 AI 员工上岗,营销、客服、运营、销售一次配齐
瓴羊AgentOne推出四大AI员工(销售、客服、运营、营销),深度融合企业数据、场景与业务系统,实现从“能聊”到“能干”的跃迁。依托“大模型×好数据×强场景”公式,构建“能信、能干、能打”三角能力,端到端交付GMV、解决率等真实业务结果。
|
5月前
|
存储 人工智能 搜索推荐
AI Agent长期记忆机制设计:从短期上下文到持久知识存储
AI Agent长期记忆是其实现个性化、持续任务与智能协作的核心基础设施。本文系统阐述分层记忆架构(L0-L4),涵盖工作记忆、任务状态、用户画像、经验沉淀与知识库,并详解Redis/SQL/向量/图数据库选型、智能检索与安全治理策略,助力构建企业级可靠记忆系统。
792 0
|
5月前
|
人工智能 前端开发 程序员
Claude Opus 5 全新发布,7 大项目实测,夯还是拉?半价吊打 Fable 5?
Claude Opus 5 模型全新发布,只用一半的价格,追平 Claude Fable 5 旗舰模型?我用 7 个实战项目测评 AI 编程能力,前端、后端和全栈开发能力如何?看到最后的例子我惊呆了
538 0
|
5月前
|
人工智能 前端开发 测试技术
测试开发一定要看懂 Agent?4 张图讲明白
本文用4张图厘清Agent核心概念:与大模型的区别、工作原理、ReAct流程,以及与ChatBot、Workflow的差异。面向测试/开发/产品人员,助力AI测试开发落地。文末征集下期选题(测试用例/自动化/缺陷分析Agent)。
|
6月前
|
数据可视化 5G
根升余弦滤波器设计与可视化(MATLAB实现)
根升余弦滤波器设计与可视化(MATLAB实现)
|
6月前
|
数据采集 人工智能 安全
AI 企业知识库系统的开发
本项目开发基于RAG技术的AI企业知识库系统,通过文档解析、智能分块、向量化索引与双路检索重排,让大模型精准调用私有资料生成可靠回答。支持多格式文档处理、细粒度权限管控及在线反馈优化,助力企业安全高效落地AI知识管理。(239字)
|
10月前
|
存储 数据采集 安全
微调与安全隐私 —— 大模型落地的合规必修课
本文聚焦大模型微调中的安全与隐私合规风险,系统剖析数据集、训练、输出三大环节的典型隐患(如敏感信息泄露、版权侵权、模型反演等),提出“脱敏+加密+过滤”全流程防护方案,并推荐合规认证平台与实操工具,助力企业实现技术落地与法律合规双保障。(239字)
|
人工智能 开发框架 监控
康存数科携手蚂蚁百宝箱共研预付式消费 AI Agent,解决预付消费信任问题助力体验升级
康存数据与蚂蚁百宝箱达成合作,联合开发预付式消费领域AI Agent,融合双方技术与行业优势,基于大模型打造覆盖消费者、商家、监管等多端的智能服务生态,推动预付消费迈向AI驱动的信任新阶段。
598 0