zoukankan      html  css  js  c++  java
  • Sharepoint 2013 通过Secure Store Service获取用户信息

    1.在用Secure Store Service获取用户信息之前需要配置SSS。

    2.以下代码是获取用户信息:

    using (SPSite site = new SPSite(webUrl))
                {
                    SecureStoreProvider prov = new SecureStoreProvider();
                    SPServiceContext context = SPServiceContext.GetContext(site);
    
                    prov.Context = context; //current user information
                    try
                    {
                        SecureStoreCredentialCollection cc = prov.GetCredentials(appId);
                        for (int i = 0; i < cc.Count; i++)
                        {
                            ISecureStoreCredential c = cc[i];
                            IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(c.Credential);
                            string sDecrypString = System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr);
                            credentialList.Add(sDecrypString);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

    注意:有的时候会在上图红线的地方报错:Secure Store Service did not performed the operation

    造成这里的原因是我们的

    SPServiceContext context = SPServiceContext.GetContext(site)的site我们用的SPContext.Current.Site.所以将此处的代码修改成如上
    using (SPSite site = new SPSite(webUrl))就可以正常解决。
  • 相关阅读:
    gearman管理
    php运行方式
    gearman mysql持久化
    gearman安装及初次使用
    消息队列各种比较
    IOC
    post提交/文件上传服务器修改
    protobuf php
    thrift 安装介绍
    qt中使用opencv处理图片 QImage 和 IplImage 相互之间转换问题
  • 原文地址:https://www.cnblogs.com/lynn-lin/p/4595737.html
Copyright © 2011-2022 走看看