マイナーでもいいよね??

殆どVB系、でも .NET じゃない VB は知らないよん

目次

Blog 利用状況

書庫

日記カテゴリ

DirectoryAccessクラスに追加したグループ関連のメソッド(VB)

DirectoryAccess クラスに追加したグループ関連のメソッドのVBのコードです。

前回追加したコードはこちら

 

'指定した ADSI オブジェクトの所属パスを取得します。

Public Shared Function GetBelongPath(native As IADs) As String  'オーバーロードを追加

  If native Is Nothing Then

    Throw New ArgumentNullException("native", "native が Nothing です。")

  End If

  Return GetBelongPath(native.ADsPath)

End Function

 

'グループを取得を取得します。GroupTokens プロパティが設定されます。

Public Shared Function GetGroups(Of T As {DirectoryObject, IGroup})() As IList(Of T)

  Dim groups As New List(Of T)()

  Using root = GetRootEntry()   'ルートのDirectoryEntryを取得

    If CanConnectDomain Then  'ドメインに接続できる時

      Dim filter = String.Format("(objectCategory={0})", CategoryType.Group)

      GroupTokens.Clear()

      Using searcher As New DirectorySearcher(root, filter)

        Using results = searcher.FindAll()

          For Each res As SearchResult In results

            Dim entry = res.GetDirectoryEntry()

            groups.Add(DirectCast(CreateInstance(entry), T))

            AddGroupToken(entry)  'PrimaryGroupTokenを追加

          Next

        End Using

      End Using

    Else  'ドメインに接続できない時  <-- こっちはローカル

      root.Children.SchemaFilter.Add(CategoryType.Group.ToString())

      For Each entry As DirectoryEntry In root.Children

        groups.Add(DirectCast(CreateInstance(entry), T))

      Next

    End If

  End Using

  Return groups

End Function

 

'指定した PrimaryGroupToken を持つドメイングループをプライマリグループとしているメンバの DirectoryEntry のコレクションを取得します。

Public Shared Function GetPrimaryGroupMemberEntries(primaryGroupToken As Integer) As IList(Of DirectoryEntry)

  If CanConnectDomain = False Then  'ドメインに接続できない時

    Return New List(Of DirectoryEntry)()

  End If

 

  Dim entries As New List(Of DirectoryEntry)()

  Using root = GetRootEntry()   'ルートのDirectoryEntryを取得

    Dim filter = String.Format("(&(|(objectCategory={0})(objectCategory={1}))(primaryGroupID={2}))",

      CategoryType.User, CategoryType.Computer, primaryGroupToken)

    Using results = searcher.FindAll()

      For Each res As SearchResult In results

        entries.Add(res.GetDirectoryEntry())

      Next

    End Using

  End Using

  Return entries

End Function

 

'指定した LDAP パスの名前(オブジェクト名)を取得します。

Public Shared Function PathToCn(ldapPath As String) As String

  If ldapPath Is Nothing Then

    Throw New ArgumentNullException("ldapPath", "ldapPath が Nothing です。")

  End If

 

  Dim spos = ldapPath.IndexOf("="c) + 1

  If spos = 0 Then

    Return ldapPath

  End If

 

  Dim epos = ldapPath.IndexOf(","c)

  If epos > 0 Then

    Return ldapPath.Substring(spos, epos - spos)

  Else

    Return ldapPath.Substring(spos)

  End If

End Function

 

'PrimaryGroupToken を追加します。

Private Shared Sub AddGroupToken(entry As DirectoryEntry)

  entry.Invoke("GetInfoEx", New Object() {"primaryGroupToken"}, 0)

  Dim token = Convert.ToInt32(entry.Properties.Item("primaryGroupToken").Value)

  GroupTokens.Add(token, entry.Properties.Item("cn").Value.ToString())

End Sub

 

DirectoryObject のインスタンスを作成する CreateInstance メソッドにグループ部分のコード(太字の部分)を追加しました。

Private Shared Function CreateInstance(entry As DirectoryEntry) As DirectoryObject

  Dim category As CategoryType

  If [Enum].TryParse(Of CategoryType)(entry.SchemaClassName, True, category) = False Then

    Throw New ArgumentException("entry の種類が CategoryType に該当しません。", "entry")

  End If

 

  Select Case category

    Case CategoryType.User

      If CanConnectDomain Then    'ドメインに接続できる時

        Return New DomainUser(entry)

      Else    'ドメインに接続できない時

        Return New LocalUser(entry)

      End If

    Case CategoryType.Group

      If CanConnectDomain Then    'ドメインに接続できる時

        Return New DomainGroup(entry)

      Else    'ドメインに接続できない時

        Return New LocalGroup(entry)

      End If

    Case Else

      Throw New NotImplementedException()

  End Select

End Function

投稿日時 : 2013年8月22日 23:55

コメントを追加

# Because the admin of this web page is working, no question very rapidly it will be renowned, due to its quality contents. 2021/09/01 0:51 Because the admin of this web page is working, no

Because the admin of this web page is working, no question very rapidly it
will be renowned, due to its quality contents.

# My spouse and I stumbled over here coming from a different website and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page for a second time. 2021/09/02 4:53 My spouse and I stumbled over here coming from a

My spouse and I stumbled over here coming from
a different website and thought I might as well check things out.
I like what I see so i am just following you. Look forward to finding out
about your web page for a second time.

# My spouse and I stumbled over here coming from a different website and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page for a second time. 2021/09/02 4:54 My spouse and I stumbled over here coming from a

My spouse and I stumbled over here coming from
a different website and thought I might as well check things out.
I like what I see so i am just following you. Look forward to finding out
about your web page for a second time.

# My spouse and I stumbled over here coming from a different website and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page for a second time. 2021/09/02 4:55 My spouse and I stumbled over here coming from a

My spouse and I stumbled over here coming from
a different website and thought I might as well check things out.
I like what I see so i am just following you. Look forward to finding out
about your web page for a second time.

# My spouse and I stumbled over here coming from a different website and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page for a second time. 2021/09/02 4:56 My spouse and I stumbled over here coming from a

My spouse and I stumbled over here coming from
a different website and thought I might as well check things out.
I like what I see so i am just following you. Look forward to finding out
about your web page for a second time.

# It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website 2021/09/02 17:38 It's a shame you don't have a donate button! I'd w

It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog!
I suppose for now i'll settle for bookmarking and adding your RSS
feed to my Google account. I look forward to new updates and will talk about this
website with my Facebook group. Chat soon!

# It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website 2021/09/02 17:39 It's a shame you don't have a donate button! I'd w

It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog!
I suppose for now i'll settle for bookmarking and adding your RSS
feed to my Google account. I look forward to new updates and will talk about this
website with my Facebook group. Chat soon!

# It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website 2021/09/02 17:40 It's a shame you don't have a donate button! I'd w

It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog!
I suppose for now i'll settle for bookmarking and adding your RSS
feed to my Google account. I look forward to new updates and will talk about this
website with my Facebook group. Chat soon!

# It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website 2021/09/02 17:41 It's a shame you don't have a donate button! I'd w

It's a shame you don't have a donate button! I'd without a doubt donate to this fantastic blog!
I suppose for now i'll settle for bookmarking and adding your RSS
feed to my Google account. I look forward to new updates and will talk about this
website with my Facebook group. Chat soon!

# Thanks for sharing such a fastidious thinking, post is fastidious, thats why i have read it completely 2021/09/04 19:31 Thanks for sharing such a fastidious thinking, pos

Thanks for sharing such a fastidious thinking, post is fastidious,
thats why i have read it completely

# Thanks for sharing such a fastidious thinking, post is fastidious, thats why i have read it completely 2021/09/04 19:33 Thanks for sharing such a fastidious thinking, pos

Thanks for sharing such a fastidious thinking, post is fastidious,
thats why i have read it completely

# Thanks for sharing such a fastidious thinking, post is fastidious, thats why i have read it completely 2021/09/04 19:34 Thanks for sharing such a fastidious thinking, pos

Thanks for sharing such a fastidious thinking, post is fastidious,
thats why i have read it completely

# Thanks for sharing such a fastidious thinking, post is fastidious, thats why i have read it completely 2021/09/04 19:35 Thanks for sharing such a fastidious thinking, pos

Thanks for sharing such a fastidious thinking, post is fastidious,
thats why i have read it completely

# Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website? My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of the information you present here. Please let 2021/09/06 6:41 Do you mind if I quote a couple of your articles a

Do you mind if I quote a couple of your articles as long
as I provide credit and sources back to your website?

My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of
the information you present here. Please let me know if this alright with you.
Thanks a lot!

# Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website? My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of the information you present here. Please let 2021/09/06 6:42 Do you mind if I quote a couple of your articles a

Do you mind if I quote a couple of your articles as long
as I provide credit and sources back to your website?

My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of
the information you present here. Please let me know if this alright with you.
Thanks a lot!

# Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website? My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of the information you present here. Please let 2021/09/06 6:43 Do you mind if I quote a couple of your articles a

Do you mind if I quote a couple of your articles as long
as I provide credit and sources back to your website?

My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of
the information you present here. Please let me know if this alright with you.
Thanks a lot!

# Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website? My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of the information you present here. Please let 2021/09/06 6:44 Do you mind if I quote a couple of your articles a

Do you mind if I quote a couple of your articles as long
as I provide credit and sources back to your website?

My blog is in the very same niche as yours and my visitors would definitely benefit from a lot of
the information you present here. Please let me know if this alright with you.
Thanks a lot!

# Ahaa, its pleasant dialogue concerning this post here at this weblog, I have read all that, so at this time me also commenting here. ps4 games https://bitly.com/3z5HwTp ps4 2021/09/12 23:11 Ahaa, its pleasant dialogue concerning this post h

Ahaa, its pleasant dialogue concerning this post here at this weblog,
I have read all that, so at this time me also commenting here.
ps4 games https://bitly.com/3z5HwTp ps4

# Ahaa, its pleasant dialogue concerning this post here at this weblog, I have read all that, so at this time me also commenting here. ps4 games https://bitly.com/3z5HwTp ps4 2021/09/12 23:12 Ahaa, its pleasant dialogue concerning this post h

Ahaa, its pleasant dialogue concerning this post here at this weblog,
I have read all that, so at this time me also commenting here.
ps4 games https://bitly.com/3z5HwTp ps4

# Ahaa, its pleasant dialogue concerning this post here at this weblog, I have read all that, so at this time me also commenting here. ps4 games https://bitly.com/3z5HwTp ps4 2021/09/12 23:13 Ahaa, its pleasant dialogue concerning this post h

Ahaa, its pleasant dialogue concerning this post here at this weblog,
I have read all that, so at this time me also commenting here.
ps4 games https://bitly.com/3z5HwTp ps4

# Ahaa, its pleasant dialogue concerning this post here at this weblog, I have read all that, so at this time me also commenting here. ps4 games https://bitly.com/3z5HwTp ps4 2021/09/12 23:14 Ahaa, its pleasant dialogue concerning this post h

Ahaa, its pleasant dialogue concerning this post here at this weblog,
I have read all that, so at this time me also commenting here.
ps4 games https://bitly.com/3z5HwTp ps4

# You really make it seem so easy with your presentation but I find this matter to be really something which I think I would never understand. It seems too complicated and very broad for me. I'm looking forward for your next post, I will try to get the h 2021/09/13 0:28 You really make it seem so easy with your presenta

You really make it seem so easy with your presentation but I
find this matter to be really something which I think I would never understand.
It seems too complicated and very broad for me. I'm looking forward for your next post, I will
try to get the hang of it! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# Stunning quest there. What happened after? Thanks! part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/ 2021/10/22 19:58 Stunning quest there. What happened after? Thanks

Stunning quest there. What happened after? Thanks! part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/

# Spot on with this write-up, I honestly believe that this web site needs much more attention. I'll probably be returning to read more, thanks for the info! 2021/10/26 6:59 Spot on with this write-up, I honestly believe tha

Spot on with this write-up, I honestly believe
that this web site needs much more attention. I'll probably be returning to read more, thanks for the info!

# Spot on with this write-up, I honestly believe that this web site needs much more attention. I'll probably be returning to read more, thanks for the info! 2021/10/26 7:00 Spot on with this write-up, I honestly believe tha

Spot on with this write-up, I honestly believe
that this web site needs much more attention. I'll probably be returning to read more, thanks for the info!

# I do not know if it's just me or if perhaps everybody else encountering problems with your website. It appears as if some of the text on your content are running off the screen. Can somebody else please comment and let me know if this is happening to th 2021/11/12 17:39 I do not know if it's just me or if perhaps everyb

I do not know if it's just me or if perhaps everybody else encountering
problems with your website. It appears as if some of the text on your
content are running off the screen. Can somebody else please comment and let me
know if this is happening to them too? This may be a
problem with my web browser because I've had this happen previously.
Appreciate it

# I do not know if it's just me or if perhaps everybody else encountering problems with your website. It appears as if some of the text on your content are running off the screen. Can somebody else please comment and let me know if this is happening to th 2021/11/12 17:40 I do not know if it's just me or if perhaps everyb

I do not know if it's just me or if perhaps everybody else encountering
problems with your website. It appears as if some of the text on your
content are running off the screen. Can somebody else please comment and let me
know if this is happening to them too? This may be a
problem with my web browser because I've had this happen previously.
Appreciate it

# I do not know if it's just me or if perhaps everybody else encountering problems with your website. It appears as if some of the text on your content are running off the screen. Can somebody else please comment and let me know if this is happening to th 2021/11/12 17:41 I do not know if it's just me or if perhaps everyb

I do not know if it's just me or if perhaps everybody else encountering
problems with your website. It appears as if some of the text on your
content are running off the screen. Can somebody else please comment and let me
know if this is happening to them too? This may be a
problem with my web browser because I've had this happen previously.
Appreciate it

# I do not know if it's just me or if perhaps everybody else encountering problems with your website. It appears as if some of the text on your content are running off the screen. Can somebody else please comment and let me know if this is happening to th 2021/11/12 17:42 I do not know if it's just me or if perhaps everyb

I do not know if it's just me or if perhaps everybody else encountering
problems with your website. It appears as if some of the text on your
content are running off the screen. Can somebody else please comment and let me
know if this is happening to them too? This may be a
problem with my web browser because I've had this happen previously.
Appreciate it

# india buy prednisone online https://prednisonesnw.com/#
buy prednisone from india 2021/11/13 9:39 Prednisone

india buy prednisone online https://prednisonesnw.com/#
buy prednisone from india

# bimatoprost generic https://bimatoprostrx.com
bimatoprost generic best price
2021/12/13 16:09 Hksfnjkh

bimatoprost generic https://bimatoprostrx.com
bimatoprost generic best price

# ivermectin price uk http://stromectolabc.com/
ivermectin cream 2022/02/08 2:49 Busjdhj

ivermectin price uk http://stromectolabc.com/
ivermectin cream

# price of clomid http://clomidus.store/ 2022/04/12 12:25 Clomids

price of clomid http://clomidus.store/

# eYOQWFBDrbkH 2022/04/19 11:56 markus

http://imrdsoacha.gov.co/silvitra-120mg-qrms

# 30mg prednisone https://deltasone.icu/
prednisone 60 mg price 2022/08/22 9:14 Prednisone

30mg prednisone https://deltasone.icu/
prednisone 60 mg price

# paxlovid mechanism of action https://paxlovid.best/
buy paxlovid covid 2022/09/08 7:40 Paxlovid

paxlovid mechanism of action https://paxlovid.best/
buy paxlovid covid

# what is the best ed pill https://ed-pills.xyz/
ed pills for sale 2022/09/16 7:07 EdPills

what is the best ed pill https://ed-pills.xyz/
ed pills for sale

# medication for ed dysfunction https://ed-pills.xyz/
best ed pills at gnc 2022/09/16 19:11 EdPills

medication for ed dysfunction https://ed-pills.xyz/
best ed pills at gnc

# doxycycline generic https://buydoxycycline.icu/ 2022/10/08 11:39 Doxycycline

doxycycline generic https://buydoxycycline.icu/

# the dating game https://datingtopreview.com/
dating service hotmail south africa 2022/10/17 20:38 Dating

the dating game https://datingtopreview.com/
dating service hotmail south africa

#  https://clomidforsale.site/ 2022/11/13 14:02 ForSale

https://clomidforsale.site/

# What side effects can this medication cause? Prescription Drug Information, Interactions & Side.
https://edonlinefast.com
Read information now. Read information now. 2023/02/17 16:57 EdPills

What side effects can this medication cause? Prescription Drug Information, Interactions & Side.
https://edonlinefast.com
Read information now. Read information now.

# where can i get doxycycline - https://doxycyclinesale.pro/# 2023/04/21 17:20 Doxycycline

where can i get doxycycline - https://doxycyclinesale.pro/#

# buying prednisone without prescription - https://prednisonesale.pro/# 2023/04/22 4:36 Prednisone

buying prednisone without prescription - https://prednisonesale.pro/#

# order cytotec online - https://cytotecsale.pro/# 2023/04/28 23:31 Cytotec

order cytotec online - https://cytotecsale.pro/#

# over the counter ear drops https://overthecounter.pro/# 2023/05/08 18:16 OtcJikoliuj

over the counter ear drops https://overthecounter.pro/#

# generic for valtrex buy without a prescription https://valtrex.auction/ valtrex 500 mg tablets 2023/10/24 17:45 Valtrex

generic for valtrex buy without a prescription https://valtrex.auction/ valtrex 500 mg tablets

タイトル
名前
URL
コメント