具有 Active Directory 的 SharePoint 自定义 Web 部件
我目前正在开发一个自定义 SharePoint Web 部件(WSS 3.0,而不是 MOSS),它将提取 Active Directory 中所有用户的信息以构建最新的员工目录。此 Web 部件显示电话号码、地址和其他类似字段等内容。我遇到的问题是,默认情况下,IIS 上的 SharePoint 网站以用户 IUSR_ 身份运行。该用户无权访问 Active Directory,因此我无法检索任何用户信息。
为了解决这个问题进行测试,我对测试用户的凭据进行了硬编码,我只是为此目的添加了该凭据。显然,这并不理想。如果有人删除了这个用户或者更改了密码,那么 Web 部件就会崩溃,并且他们将无法修复它(一旦我完成这里,他们就没有内部开发人员来接管它)。为了解决此问题,我想在 Web 部件上创建用户名/密码自定义属性,以便我可以将它们传递到 Active Directory 以检索我需要的信息。我遇到的问题是密码以纯文本形式存储,因此任何人都可以读取它。我希望它显示为 ******** 或类似的内容。有没有办法将 Web 部件上的自定义属性设置为密码类型?
如果这是不可能的,任何人都可以推荐另一种方法来完成我想做的事情吗?目前我无法更改 SharePoint 网站运行的用户。不过,如果我找不到任何其他解决方案,我会再次尝试说服他们。
提前致谢!
I am currently working on a custom SharePoint web part (WSS 3.0, not MOSS) that will pull in information for all of the users in Active Directory to build an up to date employee directory. This web part shows things like phone number, address, and other similar fields. The issue that I am having is that, by default, the SharePoint web site on IIS is running as the user IUSR_. This user does not have access to Active Directory, so I am unable to retrieve any user information.
To get around this for testing I have hard coded the credentials for a test user which I added just for this purpose. This, obviously, is not ideal. If anyone removes this user or if they ever change the password then the web part will break and they will have no way to fix it (they have no in-house developers to take it over once I am finished here). To fix this problem, I would like to make the Username/Password custom properties on the web part so I can pass those to Active Directory to retrieve the information I need. The issue I am having with this is that the password is stored in plain text so anyone can read it. I would like it to display as ******** or something similar. Is there a way to make a custom property on a web part a password type?
If this isn't possible, can anyone recommend another way to accomplish what I am trying to do? At this time I cannot change the user that the SharePoint website runs as. Although, if I cannot find any other solutions I will try again to persuade them.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们为此使用服务帐户。该服务帐户仅用于此目的。类似于 DOMAIN\SPS_AD_READ_CUSTOMER
在我们将应用程序投入生产时提供的文档中,该帐户被放入运行 Web 部件所需的内容列表中。如果 Web 部件出现故障,ITPro 可以转到该章节并检查一切是否仍然正常。
这并不理想,但我真的不知道如何解决它的另一种方法。
We use a service account for that. That service account is solely used for that. Something like DOMAIN\SPS_AD_READ_CUSTOMER
In our documentation that we deliver when putting the application in production that account is put in the list of stuff that is needed to make the webpart run. If the webpart ever fails, the ITPro can go to the chapter and check if everything is still ok.
It's not ideal, but I don't really know another way on how to fix it.
我会使用自定义编辑器部分,然后设置TextBox控件,并将属性TextBoxMode设置为密码,然后重写 EditorPart 类型的方法 - SynchChanges() 和 ApplyChanges() 来设置和检索值。
提示:首先重写 WebPart 类型的 CreateEditorParts 方法。
I would go with custom Editor Part, then set up a control of TextBox with property TextBoxMode set to Password, then override methods from type EditorPart - SynchChanges() and ApplyChanges() to set and retrieve values.
tip: override method CreateEditorParts of a WebPart type to start with.