简体   繁体   English

用户定义的函数返回名字和姓氏或任何其他选项?

[英]User defined function to return the firstname and lastname or any other option?

In an SQL table, we have stored the username only, and that info is shown in a gridview in a web application in .net (Sharepoint application page) 在一个SQL表中,我们仅存储了username ,并且该信息显示在.net(Sharepoint应用程序页面)中Web应用程序的gridview中

We use this column for security reasons, add the user to the specific sharepoint group, etc. However we want to show the firstname, lastname . 出于安全原因,我们使用此列,将用户添加到特定的共享点组,等等。但是,我们要显示firstname, lastname

I thought 2 options: 我认为有两种选择:

  1. Create an UDF in .net, and inside it, query active directory? 在.net中创建UDF,并在其中查询活动目录? Then use the UDF in the stored procedure to return the firstname, lastname 然后在存储过程中使用UDF返回名字,姓氏
  2. In the gridview row databound event, take value of the username and do the same logic that we would implement in the UDF and then replace the cell contents 在gridview行数据绑定事件中,获取用户名的值,并执行与在UDF中实现的逻辑相同的逻辑,然后替换单元格内容

Is there any other option? 还有其他选择吗? What do you think about my options? 您如何看待我的选择?

I think that this should not be done in the database, so I would not do 1. 我认为不应在数据库中执行此操作,因此我不会执行1。

Option 2. looks more promising. 选项2看起来更有希望。 However, I don't like how it's easy to miss this logic when someone is reading your code. 但是,我不喜欢有人阅读您的代码时容易错过此逻辑。

You could use something like model binding: http://www.asp.net/web-forms/tutorials/data-access/model-binding/retrieving-data 您可以使用类似模型绑定的方法: http : //www.asp.net/web-forms/tutorials/data-access/model-binding/retrieving-data

You would replace studentsGrid_GetData with the function to look up user data. 您可以使用该函数替换studentsGrid_GetData来查找用户数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 姓氏名验证 - LastName FirstName validation 在广告中搜索姓氏和名字 - Search LastName and FirstName in AD 如何使用标记扩展方法在 xaml 中连接 FirstName 和 LastName 以显示用户的全名 - How can i concatenate FirstName and LastName in xaml using markup extension method to show full name of user 从文本中获取姓氏/名字的正则表达式 - Regular Expression to get LastName / FirstName from a text 使用linq从lastname +“,” + firstname的组合中搜索名字 - search firstname from combination of lastname+“, ”+firstname using linq 如何在SQL中组合firstname和lastname并使用LIKE进行搜索 - how to combine firstname and lastname in SQL and search with LIKE 当有“FirstName”和“LastName”时,属性“FullName”是否错误? - Is a property “FullName” bad, when there are “FirstName” and “LastName”? 遍历FirstName,LastName创建用户名的技术 - technique to iterate through the FirstName, LastName to create username 如何在 Azure Web App 上托管的 Web 表单中检索当前的 Azure AD 用户信息(电子邮件、名字、姓氏)? - How can I retrieve current Azure AD User informations (email, firstname, lastname) in web-forms hosted on Azure Web App? 为什么我在SQL表中获得@firstname和@lastname? - Why do I get @firstname and @lastname in my SQL table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM