技术笔记:MOSS&SSO系列1

本文涉及的产品
语种识别,语种识别 100万字符
文档翻译,文档翻译 1千页
图片翻译,图片翻译 100张
简介: 技术笔记: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

相关文章
|
7月前
|
数据安全/隐私保护
使用校园账号登录WOS(Web of Science)并检索文献
使用校园账号登录WOS(Web of Science)并检索文献
471 0
|
11月前
|
Kubernetes 数据安全/隐私保护 容器
【k8s 系列】k8s 学习二十八,k8s 认证和权限控制
说到 k8s 的认证机制,其实之前咋那么也有提到过 ServiceAccouont ,以及相应的 token ,证书 crt,和基于 HTTP 的认证等等
214 0
|
人工智能 自然语言处理 开发工具
免费部署一个开源大模型 MOSS
近日复旦大学自然语言处理实验室邱锡鹏教授团队研发的大语言模型 MOSS 也已公开发布并开源。MOSS 的公开发布无疑加剧了国内 ChatGPT 式产品的竞争。
1487 1
|
前端开发
谷粒学苑项目实战(十五):实现单点登录与注册功能
谷粒学苑项目实战(十五):实现单点登录与注册功能
131 0
|
前端开发 JavaScript API
微信开发系列之三 - 在微信公众号里发起SAP C4C Account的创建
微信开发系列之三 - 在微信公众号里发起SAP C4C Account的创建
110 0
微信开发系列之三 - 在微信公众号里发起SAP C4C Account的创建
|
存储 NoSQL JavaScript
SAP系统和微信集成的系列教程之六:如何通过OAuth2获取微信用户信息并显示在SAP UI5应用中
SAP系统和微信集成的系列教程之六:如何通过OAuth2获取微信用户信息并显示在SAP UI5应用中
SAP系统和微信集成的系列教程之六:如何通过OAuth2获取微信用户信息并显示在SAP UI5应用中
|
监控 安全 Oracle
2014年最热门的十八大IT认证
Foote partners最近在跟踪分析641个IT认证的薪酬指数并调查了北美2522家企业15.4万IT员工后,给出了2014十八大热门IT认证榜单,从中我们可以看出系统架构、信息安全和数据库类认证最为吃香。
141 0
2014年最热门的十八大IT认证