代码之家  ›  专栏  ›  技术社区  ›  Matthew Iselin

VB。NET:已登录的用户信息

  •  2
  • Matthew Iselin  · 技术社区  · 16 年前

    我正在用VB编写软件。NET(2005),它使用Windows用户信息作为登录凭据,只使用用户名。我找到了环境。用户名,适用于用户名(如您所期望的)。

    但是,我需要更多信息-我需要用户的全名(如“开始”菜单上所示)。似乎这些信息已被存储。..在某个地方,因为Windows能够将其用于文件共享权限等。

    我听说user32.dll中有一些调用可以做到这一点,但我想要一个。NET方法,如果可能的话。我还有一个用户的SID,如果这有帮助的话。

    1 回复  |  直到 5 年前
        1
  •  1
  •   Matthew Iselin    16 年前

    这似乎是系统。DirectoryServices命名空间正是我要找的。

    你似乎总是在问完问题后立即找到答案:)

    供将来参考:

    Dim ent As New DirectoryServices.DirectoryEntry("WinNT://<Domain>/<Username>")
    Dim props As DirectoryServices.PropertyCollection = ent.Properties
    Debug.Print(props.Item("FullName").Value)