久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 asp.net 獲取驗證 AD 用戶 objectGuid

Getting authenticate AD users objectGuid from asp.net(從 asp.net 獲取驗證 AD 用戶 objectGuid)
本文介紹了從 asp.net 獲取驗證 AD 用戶 objectGuid的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 ASP.NET 應用程序中使用 Windows 身份驗證.我想知道如何最好地從當前登錄的用戶那里獲取 objectGuid?

I am using windows authentication within an ASP.NET application. I am wondering how to best get the objectGuid from the currently logged in user?

問候,埃吉爾.

推薦答案

您可以使用 System.DirectoryServices 命名空間執行此操作.

You can do this with the System.DirectoryServices namespace.

Dim entry As DirectoryServices.DirectoryEntry
Dim mySearcher As System.DirectoryServices.DirectorySearcher
Dim result As System.DirectoryServices.SearchResult
Dim myEntry As DirectoryEntry
Dim domainName As String
Dim userId As String
Dim objectGuid As Guid

'Split the username into domain and userid parts
domainName = Page.User.Identity.Name.Substring(0, Page.User.Identity.Name.IndexOf(""))
userId = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("") + 1)

'Start at the top level domain
entry = New DirectoryEntry(domainName)

mySearcher = New DirectorySearcher(entry)

'Build a filter for just the user
mySearcher.Filter = ("(&(anr=" & userId & ")(objectClass=user))")

'Get the search result ...
result = mySearcher.FindOne

'... and then get the AD entry that goes with it
myEntry = result.GetDirectoryEntry

'The Guid property is the objectGuid
objectGuid = myEntry.Guid

可能有更好的方法來做到這一點,但這是有效的!

There might be a better way to do this, but this works!

這篇關于從 asp.net 獲取驗證 AD 用戶 objectGuid的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Asp.net System.Web.HttpContext.Current.Session null in global.asax(Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中為 null)
Caught exception is null itself !(捕獲的異常本身為空!)
Is an empty textbox considered an empty string or null?(空文本框被視為空字符串還是 null?)
UserPrincipals.GetAuthorizationGroups An error (1301) occurred while enumerating the groups. After upgrading to Server 2012 Domain Controller(UserPrincipals.GetAuthorizationGroups 枚舉組時發生錯誤 (1301).升級到 Server 2012 域控制
Using PrincipalSearcher to find users with quot;orquot; parameters(使用 PrincipalSearcher 查找帶有“或的用戶參數)
Get members of an Active Directory group recursively, i.e. including subgroups(遞歸獲取 Active Directory 組的成員,即包括子組)
主站蜘蛛池模板: 亚洲精品小视频在线观看 | 蜜臀久久99精品久久久久野外 | 欧美精品成人一区二区三区四区 | 国产精品免费一区二区三区 | www.五月天婷婷 | 91在线网站 | 最新中文字幕一区 | 成人av免费看 | 一区二区三区亚洲精品国 | 美女视频h | 日韩免费视频 | 国产一区二区三区久久久久久久久 | 中文字幕一区在线观看视频 | 中文字幕久久精品 | 久久视频精品 | 欧美精品一区二区三区在线播放 | 国产精品毛片一区二区在线看 | 色综合一区二区 | 97精品国产97久久久久久免费 | 国产成人久久精品 | 56pao在线 | 国产一二区视频 | 欧美综合国产精品久久丁香 | 欧美一区二区三区在线观看视频 | 亚洲a人| 精品久久香蕉国产线看观看亚洲 | 亚洲一区二区视频在线播放 | 欧美中文字幕一区二区 | 久久久久成人精品 | 99热播精品| 中文字幕精品一区二区三区精品 | 欧美精品日韩精品国产精品 | 国产精品成av人在线视午夜片 | 欧美日韩高清在线一区 | 精品国产免费一区二区三区演员表 | 激情在线视频网站 | 一区二区精品 | 欧美一级片中文字幕 | 成人在线视频免费观看 | 三级视频在线观看电影 | 狠狠涩|