可以在客户端相关代码中引用System.DirectoryServices,例如_Created代码到实体吗? [英] Can System.DirectoryServices be referenced in client related code such as _Created code to an entity ?

查看:61
本文介绍了可以在客户端相关代码中引用System.DirectoryServices,例如_Created代码到实体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Lightswitch代码构建一种访问Active Directory的方法。在以前的VB  ASP.NET代码,必须添加对System.DirectoryServices的引用。


我可以在LightSwitch中的服务器生成的代码中执行此操作,但它似乎不允许在客户端区域中文件视图。


查看客户端的原因是我希望发生以下情况:


当前的Entity_Created代码获取当前用户Application.User.Name。我正在尝试使用该用户标识并在活动目录中进行查找,以便我可以将Active Directory
中人员的姓名,电子邮件地址和电话号码预先填充到用户实体中的等效字段中,以方便用户。


我假设Entity_Created代码是这样做的地方,以便在创建实体时将其预先填充到屏幕上。我注意到当我将鼠标悬停在entity_Created的代码选择上时,它表示此代码在客户端上运行。当我将鼠标悬停在
以外的其他代码选项时,大多数人说他们在服务器上运行。


System.DirectoryServices只能在服务器上引用吗?如果是这样,"服务器"上的其他代码位置选择可以允许在创建时预先填充信息? (System.Net.Mail似乎也需要在服务器上引用 - 在这个
的情况下没问题,因为在插入项目之前不会使用它)


提前感谢任何圣人建议。

解决方案


有两件事要做在这里考虑,一个是你只能在客户端级别引用Silverlight dll,这就是为什么你不能添加对System.DirectorySewrvices的引用。另一个是,除非这是一个OOB(Out Of Browser,即"桌面")应用程序,
你会发现你可以从客户端访问的内容有额外的限制。


MyScreen_Created在客户端上运行,MyEntity_Created在服务器上运行。所以你应该可以在MyEntity_Created代码中访问Active Directory。要确保您位于正确的位置,请打开您的数据源,双击MyEntity,
然后在"编写代码"中。下拉框选择"MyEntity_Created"。在这个代码中你应该能够访问Active Directory。


替换我写的地方"MyEntity"以及您实体的实际名称,& "自选"名称为 无论你处理什么屏幕。


希望一切都有意义。


Yann


I am trying to build a means for Lightswitch code to access Active Directory. In previous VB  ASP.NET code, one had to add a reference to System.DirectoryServices.

I can do that in Server generated code in LightSwitch, but it doesnt seem to allow that in the Client area under file view.

The reason for looking at client side is that I want the following to happen:

The current Entity_Created code gets the current user through Application.User.Name. I am trying to take that userid and do a lookup in active directory so that I can prepopulate the name, email address and phone number of the person from Active Directory into the equivalent fields in the entity for the user as a convenience.

I am assuming that the Entity_Created code is the place to do that so that it gets prepopulated to the screen as the entity is created. I notice when I hover over the entity_Created choice for code it indicates this code is run on client. when I hover over the other code choices, most say they run on server.

Can System.DirectoryServices only be referenced at server ? If so, what other code location choices on 'server' could allow for prepopulation of information at time of creation ? (System.Net.Mail seems to require being referenced on Server as well -in this case that is fine, because use of it does not occur until an item is inserted)

Thanks in advance for any sage advice.

解决方案

Hi,

There's two things to consider here, one is that you can only reference Silverlight dll's at the client level, that's why you can't add a reference to System.DirectorySewrvices. The other is that unless this is an OOB (Out Of Browser, ie "desktop") app, you'll find additional restrictions on what you can access from the client.

MyScreen_Created gets run on the client, MyEntity_Created gets run on the server. So you should be fine accessing Active Directory in the MyEntity_Created code. To make sure you're in the right place, open up your data source, double-click on MyEntity, then in the "Write Code" dropdown box select "MyEntity_Created". In THAT code you should be able to access Active Directory.

Replace where I've written "MyEntity" with the actual name of your entity, & "MyScreen" with the name of whatever screen you're dealing with.

Hope that all makes sense.

Yann


这篇关于可以在客户端相关代码中引用System.DirectoryServices,例如_Created代码到实体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆