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

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

目次

Blog 利用状況

書庫

日記カテゴリ

コンピュータ用のクラス(VB)

コンピュータを表すクラス Computer クラスは DomainObject クラスを継承します。

Webアプリでデータソースとして使えるようにします。

 

<DataObject()>

Public NotInheritable Class Computer

  Inherits DomainObject

 

#Region " プライベートフィールド "

  Private ReadOnly _fullName, _role, _os, _osVer, _osSP, _site As String

#End Region

 

#Region " フレンドコンストラクタ "

  'DirectoryEntry を指定して Computer クラスの新しいインスタンスを初期化します。

  Friend Sub New(entry As DirectoryEntry)

    MyBase.New(entry)

    entry.Invoke("GetInfoEx", New Object() {"msDS-isGC", "msDS-SiteName"}, 0)

    With entry.Properties

      _fullName = DirectCast(.Item("dNSHostName").Value, String)

      _role = GetRole()   '役割を取得

      _os = DirectCast(.Item("operatingSystem").Value, String)

      _osVer = DirectCast(.Item("operatingSystemVersion").Value, String)

      _osSP = DirectCast(.Item("operatingSystemServicePack").Value, String)

      _site = DirectCast(.Item("msDS-SiteName").Value, String)

    End With

  End Sub

#End Region

 

#Region " パブリックプロパティ "

  'DNS 名を取得します。

  Public ReadOnly Property FullName As String

    Get

      Return _fullName

    End Get

  End Property

 

  'OS を取得します。

  Public ReadOnly Property OperatingSystem As String

    Get

      Return _os

    End Get

  End Property

 

  'OS のサービスパックを取得します。

  Public ReadOnly Property OperatingSystemServicePack As String

    Get

      Return _osSP

    End Get

  End Property

 

  'OS のバージョンを取得します。

  Public ReadOnly Property OperatingSystemVersion As String

    Get

      Return _osVer

    End Get

  End Property

 

  'プライマリグループ ID を取得します。

  Public ReadOnly Property PrimaryGroupId As Integer

    Get

      If MyBase.IsDisposed Then

        Throw New ObjectDisposedException(Me.GetType().Name)

      End If

      Return Convert.ToInt32(MyBase.Entry.Properties.Item("primaryGroupID").Value)

    End Get

  End Property

 

  '役割を取得します。

  Public ReadOnly Property Role As String

    Get

      Return _role

    End Get

  End Property

 

  'サイトを取得します。

  Public ReadOnly Property Site As String

    Get

      Return _site

    End Get

  End Property

#End Region

 

#Region " パブリックメソッド "

  '指定した名前のコンピュータを検索します。このメソッドはデータバインド用です。

  <DataObjectMethod(DataObjectMethodType.Select)>

  Public Shared Function FindByName(name As String) As Computer

    Return DirectCast(DirectoryAccess.FindDirectoryObject(name, CategoryType.Computer), Computer)

  End Function

 

  '所属するグループを取得します。

  Public Function GetBelongGroups(groups As IEnumerable(Of DomainGroup)) As ReadOnlyCollection(Of String)

    If groups Is Nothing Then

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

    End If

 

    Dim belongGroups = groups.Where(

      Function(group) group.Native.IsMember(MyBase.Entry.Path)).Select(Function(group) group.Name).ToList()

    belongGroups.Add(DirectoryAccess.GroupTokens.Item(Me.PrimaryGroupId))

    belongGroups.Sort()

    Return belongGroups.AsReadOnly()

  End Function

 

  '指定した名前のコンピュータの所属するグループを取得します。このメソッドはデータバインド用です。

  <DataObjectMethod(DataObjectMethodType.Select)>

  Public Shared Function GetBelongGroups(name As String) As ReadOnlyCollection(Of String)

    Dim pc = FindByName(name)   'コンピュータを検索

    Dim groups = DirectoryAccess.GetGroups(Of DomainGroup)()  'グループを取得

    Return pc.GetBelongGroups(groups)   '所属するグループを取得

  End Function

 

  'コンピュータの一覧を取得します。このメソッドはデータバインド用です。

  <DataObjectMethod(DataObjectMethodType.Select)>

  Public Shared Function GetComputers() As IList(Of Computer)

    Return DirectoryAccess.GetComputers()   'コンピュータを取得

  End Function

#End Region

 

#Region " プライベートメソッド "

  '役割を取得します。

  Private Function GetRole() As String

    Dim gc = MyBase.Entry.Properties.Item("msDS-isGC").Value

    If gc Is Nothing Then

      Return "ワークステーションまたはサーバー"

    End If

    Return If(Convert.ToBoolean(gc), "グローバル カタログ", "ドメイン コントローラー")

  End Function

#End Region

 

一覧を取得する GetComputers メソッドは内部で DirectoryAccess クラスの GetComputers メソッドを呼んでますが、これについては別途書きます。

コンピュータはユーザと同じく所属するグループがあり、プライマリ グループがあります。

プライマリ グループはユーザと同じ方法で取得しますが所属するグループは内部実装が異なります。

ユーザの場合は IADsUser.Groups メソッドで所属するグループ(プライマリ グループ以外)を取得できるんですが、コンピュータの場合はそれに相当するメソッドがありません。

また、残念なことに LDAP で取得したコンピュータは IADsComputer オブジェクトとして扱えない(DirectoryEntry.NativeObject からキャストできない)んです。なのでユーザやグループのように Native プロパティを実装してません。

仕方ないのですべてのグループを取得して、個々のグループに対してメンバであれば(IADsGroup.IsMember メソッドが True を返せば)そのグループに所属してると判断してます。

投稿日時 : 2013年11月9日 14:11

コメントを追加

# re: ???????????(VB) 2021/07/09 9:26 methotrexate side effects usmle

chloroquine drug class https://chloroquineorigin.com/# hydroxychloroquine drug class

# re: ???????????(VB) 2021/07/25 13:02 hydroxychloroquine meaning

chloroquine antimalarial https://chloroquineorigin.com/# hydrocloroquine

# re: ???????????(VB) 2021/08/09 11:29 what are the side effects of hydroxychloroquine

chloroquine vs chloroquine phosphate https://chloroquineorigin.com/# define hydroxychloroquine

# Heya i am for the first time here. I came across this board and I to find It really helpful & it helped me out much. I'm hoping to offer something back and help others such as you aided me. 2021/08/31 16:21 Heya i am for the first time here. I came across

Heya i am for the first time here. I came across this board and I to find
It really helpful & it helped me out much. I'm hoping to offer something back
and help others such as you aided me.

# WOW just what I was searching for. Came here by searching for and 2021/09/01 23:20 WOW just what I was searching for. Came here by se

WOW just what I was searching for. Came here by searching for and

# WOW just what I was searching for. Came here by searching for and 2021/09/01 23:21 WOW just what I was searching for. Came here by se

WOW just what I was searching for. Came here by searching for and

# WOW just what I was searching for. Came here by searching for and 2021/09/01 23:22 WOW just what I was searching for. Came here by se

WOW just what I was searching for. Came here by searching for and

# WOW just what I was searching for. Came here by searching for and 2021/09/01 23:23 WOW just what I was searching for. Came here by se

WOW just what I was searching for. Came here by searching for and

# I quite like looking through an article that can make people think. Also, thanks for allowing me to comment! 2021/09/02 20:41 I quite like looking through an article that can

I quite like looking through an article that can make people think.
Also, thanks for allowing me to comment!

# I quite like looking through an article that can make people think. Also, thanks for allowing me to comment! 2021/09/02 20:42 I quite like looking through an article that can

I quite like looking through an article that can make people think.
Also, thanks for allowing me to comment!

# I quite like looking through an article that can make people think. Also, thanks for allowing me to comment! 2021/09/02 20:43 I quite like looking through an article that can

I quite like looking through an article that can make people think.
Also, thanks for allowing me to comment!

# I quite like looking through an article that can make people think. Also, thanks for allowing me to comment! 2021/09/02 20:44 I quite like looking through an article that can

I quite like looking through an article that can make people think.
Also, thanks for allowing me to comment!

# Saved as a favorite, I really like your web site! quest bars http://bitly.com/3jZgEA2 quest bars 2021/09/12 1:50 Saved as a favorite, I really like your web site!

Saved as a favorite, I really like your web site!

quest bars http://bitly.com/3jZgEA2 quest bars

# Excellent goods from you, man. I have take note your stuff previous to and you're simply too wonderful. I actually like what you have received here, really like what you are saying and the best way wherein you assert it. You are making it enjoyable and y 2021/09/12 22:29 Excellent goods from you, man. I have take note yo

Excellent goods from you, man. I have take note your stuff previous
to and you're simply too wonderful. I actually like what you have received here, really like what you are saying
and the best way wherein you assert it. You are making
it enjoyable and you continue to take care of to keep it smart.

I can not wait to read much more from you. This is actually a wonderful site.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# Excellent goods from you, man. I have take note your stuff previous to and you're simply too wonderful. I actually like what you have received here, really like what you are saying and the best way wherein you assert it. You are making it enjoyable and y 2021/09/12 22:30 Excellent goods from you, man. I have take note yo

Excellent goods from you, man. I have take note your stuff previous
to and you're simply too wonderful. I actually like what you have received here, really like what you are saying
and the best way wherein you assert it. You are making
it enjoyable and you continue to take care of to keep it smart.

I can not wait to read much more from you. This is actually a wonderful site.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# Excellent goods from you, man. I have take note your stuff previous to and you're simply too wonderful. I actually like what you have received here, really like what you are saying and the best way wherein you assert it. You are making it enjoyable and y 2021/09/12 22:31 Excellent goods from you, man. I have take note yo

Excellent goods from you, man. I have take note your stuff previous
to and you're simply too wonderful. I actually like what you have received here, really like what you are saying
and the best way wherein you assert it. You are making
it enjoyable and you continue to take care of to keep it smart.

I can not wait to read much more from you. This is actually a wonderful site.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# Excellent goods from you, man. I have take note your stuff previous to and you're simply too wonderful. I actually like what you have received here, really like what you are saying and the best way wherein you assert it. You are making it enjoyable and y 2021/09/12 22:32 Excellent goods from you, man. I have take note yo

Excellent goods from you, man. I have take note your stuff previous
to and you're simply too wonderful. I actually like what you have received here, really like what you are saying
and the best way wherein you assert it. You are making
it enjoyable and you continue to take care of to keep it smart.

I can not wait to read much more from you. This is actually a wonderful site.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 9:36 When some one searches for his vital thing, theref

When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that
thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 9:37 When some one searches for his vital thing, theref

When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that
thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 9:38 When some one searches for his vital thing, theref

When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that
thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 9:39 When some one searches for his vital thing, theref

When some one searches for his vital thing, therefore he/she wishes to be available that in detail, so that
thing is maintained over here. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# znbiwluozobb 2021/11/25 13:38 cegocwph

hydrochloride cream https://chloroquineclinique.com/

# zudpccehwsbz 2021/12/03 18:30 dwedayjhqm

plaquenil hydroxychloroquine https://hydroaralenus.com/

# qiouyrmxxuhd 2021/12/03 18:35 cegojdjp

chloroquine phosphate generic name https://chloroquineetc.com/

# Pretty! This was an extremely wonderful post. Many thanks for providing this info. 2021/12/23 18:53 Pretty! This was an extremely wonderful post. Many

Pretty! This was an extremely wonderful post.

Many thanks for providing this info.

# Pretty! This was an extremely wonderful post. Many thanks for providing this info. 2021/12/23 18:53 Pretty! This was an extremely wonderful post. Many

Pretty! This was an extremely wonderful post.

Many thanks for providing this info.

# Pretty! This was an extremely wonderful post. Many thanks for providing this info. 2021/12/23 18:54 Pretty! This was an extremely wonderful post. Many

Pretty! This was an extremely wonderful post.

Many thanks for providing this info.

# Pretty! This was an extremely wonderful post. Many thanks for providing this info. 2021/12/23 18:55 Pretty! This was an extremely wonderful post. Many

Pretty! This was an extremely wonderful post.

Many thanks for providing this info.

# uyxsxnqycdpc 2022/05/13 11:52 vtbrld

hydrochloquin https://keys-chloroquineclinique.com/

# Hi there I am so happy I found your web site, I really found you by error, while I was researching on Aol for something else, Regardless I am here now and would just like to say thanks for a incredible post and a all round exciting blog (I also love the 2022/05/16 15:28 Hi there I am so happy I found your web site, I re

Hi there I am so happy I found your web site, I really found
you by error, while I was researching on Aol for something else,
Regardless I am here now and would just like to say thanks for a incredible post and a all round exciting
blog (I also love the theme/design), I don’t have time to read it all at the minute but I have saved it and also added
in your RSS feeds, so when I have time I will be back to read a lot
more, Please do keep up the awesome work.

http://www.distancelearning.wiki/index.php?title=Sort_Of_Mortgage_Broker_Fresno_Ca
https://cacophonyfarm.com/index.php/User:JaymeBeier3201
https://zoomwiki.blitwise.com/index.php/User:KristiForney71
http://wiki-intel.org/index.php?title=The_World_s_Most_Unusual_Mortgage_Loan_Calculator
http://wikibase2.digicult-verbund.de/wiki/Be_Taught_Anything_New_From_Mortgage_Lenders_In_San_Jose_Ca_Lately_We_Asked_You_Answered
https://wiki.r3public.org/index.php?title=User:ArronQuilty

# If you are going for most excellent contents like I do, only visit this web site all the time for the reason that it offers feature contents, thanks https://advkey.quest/index.php/Believe_In_Your_Mortgage_Broker_In_Albany_Ca_Skills_However_By_No_Means_S 2022/05/21 17:50 If you are going for most excellent contents like

If you are going for most excellent contents like I do,
only visit this web site all the time for the reason that it offers feature contents, thanks

https://advkey.quest/index.php/Believe_In_Your_Mortgage_Broker_In_Albany_Ca_Skills_However_By_No_Means_Stop_Bettering
https://wiki.fairspark.com/index.php/User:MaryellenOman
http://accounting.foursquare.org/wiki/index.php/Mortgage_Broker_Claremont_CA-_Name_909-451-9515-_Quick_Approval
https://lican.as.arizona.edu/~ehtsim/index.php/User:AugustaRmf
http://skc.isi.edu/workflow-design/index.php/9_Methods_To_Reinvent_Your_Mortgage_Broker
https://wiki.onchainmonkey.com/index.php?title=Imagine_In_Your_Mortgage_Broker_In_Albany_Ca_Abilities_However_Never_Stop_Enhancing

# re: コンピュータ用のクラス(VB) 2023/01/28 6:37 Optimum

The presence of Russian flags and symbols at the Australian Open has been a source of controversy throughout the tournament.

# doors2.txt;1 2023/03/14 14:48 qQZDuKVRETaDHZRtND

doors2.txt;1

# doors2.txt;1 2023/03/14 16:23 WLJcmblHBYfHX

doors2.txt;1

タイトル
名前
URL
コメント