ADSYSTEMINFO 的 VB.Net/C# 等效项是什么?在此示例中是否需要与 AD 交互?
我正在查看一些旧的 ASP 代码,其中包含以下内容:
Set objDSE = GetObject("LDAP://RootDSE")
Set objSysInfo = CreateObject("adsysteminfo")
Set objUser= Getobject("LDAP://" & Replace(objSysInfo.UserName,"/","\/"))
dtmValue = objUser.PasswordLastChanged
objMaxPwdAge = GetObject("LDAP://" & objDSE.get("DefaultNamingContext")).maxPwdAge
dblMaxPwdDays = Abs(objMaxPwdAge.HighPart * 2^32 + objMaxPwdAge.LowPart) _
* ONE_HUNDRED_NANOSECOND / SECONDS_IN_DAY
pwdExpDate = dtmValue + dblMaxPwdDays
这是用于使用集成身份验证的 Intranet 应用程序。
ASP adsysteinfo 对象有替代品吗?我可能可以使用 System.DirectoryServices.DirectoryEntry 移植大多数 LDAP 调用,但是在 ASP.NET(VB.Net 或 C#)中是否有更好/更简单的方法来执行此操作?
有没有关于如何将 ASP 对象属性转换为 DirectoryEntry 属性的文档?
I'm looking at some old ASP code that contains the following:
Set objDSE = GetObject("LDAP://RootDSE")
Set objSysInfo = CreateObject("adsysteminfo")
Set objUser= Getobject("LDAP://" & Replace(objSysInfo.UserName,"/","\/"))
dtmValue = objUser.PasswordLastChanged
objMaxPwdAge = GetObject("LDAP://" & objDSE.get("DefaultNamingContext")).maxPwdAge
dblMaxPwdDays = Abs(objMaxPwdAge.HighPart * 2^32 + objMaxPwdAge.LowPart) _
* ONE_HUNDRED_NANOSECOND / SECONDS_IN_DAY
pwdExpDate = dtmValue + dblMaxPwdDays
This is for an intranet app that uses integrated authentication.
Is there a replacement for the ASP adsysteinfo object? I can probably port most of the LDAP calls using System.DirectoryServices.DirectoryEntry
, but is there a better/easier way to do this in ASP.NET (VB.Net or C#)?
Is there any documentation for how to convert the ASP object properties to DirectoryEntry properies?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例代码中,adsysteminfo 仅用于检索当前用户名。在 ASP.Net 应用程序中,您可以通过以下两种方式之一获取此信息,具体取决于您的配置:
1) 如果您模拟每个用户,那么您应该能够使用:
2) 如果您不是模拟用户,而是您确实有集成身份验证作为网站的唯一安全机制,那么您可以按如下方式获取用户的域名:
至于其他 LDAP 调用,System.DirectoryServices 肯定是您想要使用的。下面是我们如何连接到 AD 并开始搜索用户的示例:
然后我们可以使用 m_Searcher 开始从 AD 中提取我们需要的内容(这只是使用目录服务的一个示例)。
In your example code, adsysteminfo is just use to retrieve the current user name. In an ASP.Net application, you can get this one of two ways, depending on your configuration:
1) If you are impersonating each user, then you should be able to use:
2) If you are not impersonating the user, but you do have integrated authentication as the only security mechanism for the web site, then you can get the user's domain name as follows:
As for the other LDAP call, System.DirectoryServices is definitely what you want to use. Here is a sample of how we get hooked into AD to start searching for users:
Then we can use m_Searcher to start extracting what we need from AD (this is just one example for using directory services).