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

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

目次

Blog 利用状況

書庫

日記カテゴリ

Active Directoryデータのプロパティ出力(VB)

ドメインのユーザ、グループ、コンピュータなどの Active Directory データは DirectoryEntry で表されます。

どういうプロパティ(属性)があるかはオブジェクトによって異なります。

設定した項目は通常、プロパティ(DirectoryEntry.Properties プロパティ:PropertyCollection クラス)に含まれるので、簡単に取得できます。(設定してない項目は含まれないので取得できません。)

オプションのプロパティも ADSI の IADsClass.OptionalProperties プロパティから簡単に取得できます。

プロパティとオプションのプロパティをテキストファイルに出力するサンプルです。対象データと出力ファイルパスを受け取ります。

※ActiveDs、System.IO、System.Security.Principal、System.Text をインポート

 

Private Sub OutputProperties(entry As DirectoryEntry, filePath As String)

  Dim props = entry.Properties.PropertyNames.Cast(Of String)().OrderBy(Function(s) s).ToList()  'プロパティ名のリスト

  Using writer As New StreamWriter(filePath, False, Encoding.UTF8)

    For Each pname In props   'プロパティ数分

      Dim val = entry.Properties.Item(pname).Value

      If TypeOf val Is Byte() Then  'バイト配列の時

        Dim pstr = GetByteValue(pname, DirectCast(val, Byte()))   '値を取得

        writer.WriteLine("{0}:{1}", pname, pstr)

      Else  'バイト配列以外の時

        For Each pval In entry.Properties.Item(pname)   '値数分

          writer.WriteLine("{0}:{1}", pname, pval)

        Next

      End If

    Next

  End Using

End Sub

 

Private Sub OutputOptionalProperties(entry As DirectoryEntry, filePath As String)

  Dim adsi = DirectCast(entry.NativeObject, IADs)   'ADSI オブジェクト

  Dim schema = DirectCast(entry.SchemaEntry.NativeObject, IADsClass'スキーマ オブジェクト

  Dim val As Object

  Using writer As New StreamWriter(filePath, False, Encoding.UTF8)

    adsi.GetInfoEx(DirectCast(schema.OptionalProperties, Object()), 0'プロパティの値をディレクトリ ストアから読込

    For Each pname As String In DirectCast(schema.OptionalProperties, IEnumerable'オプションのプロパティ数分

      Try

        val = adsi.GetEx(pname)

      Catch

        writer.WriteLine("{0}:<未設定>", pname)

        Continue For

      End Try

 

      If TypeOf val Is Byte() Then  'バイト配列の時

        Dim bstr = BitConverter.ToString(DirectCast(val, Byte()))

        writer.WriteLine("{0}:{1}", pname, bstr)

      Else  'バイト配列以外の時

        For Each pval In DirectCast(val, IEnumerable)   '値数分

          If TypeOf pval Is Byte() Then  'バイト配列の時

            Dim pstr = GetByteValue(pname, DirectCast(pval, Byte()))   '値を取得

            writer.WriteLine("{0}:{1}", pname, pstr)

          Else  'バイト配列以外の時

            writer.WriteLine("{0}:{1}", pname, pval)

          End If

        Next

      End If

    Next

  End Using

End Sub

 

'値を取得

Private Function GetByteValue(name As String, value As Byte()) As String

  If name.Equals("objectSid") Then

    Return New SecurityIdentifier(value, 0).ToString()

  ElseIf name.Equals("objectGUID") Then

    Return New Guid(value).ToString()

  Else

    Return BitConverter.ToString(value)

  End If

End Function

 

COM Object になっている属性は型名(System.__ComObject)が出力されます。

Domain Admins グループの出力結果です。(左:プロパティ、右:オプションのプロパティ)

※どちらもクリックすると新しいウィンドウで拡大図が表示されます。

Properties OptionalProperties

投稿日時 : 2013年9月19日 0:52

コメントを追加

# Marvelous, what a website it is! This web site presents useful data to us, keep it up. 2019/06/01 16:40 Marvelous, what a website it is! This web site pre

Marvelous, what a website it is! This web site presents
useful data to us, keep it up.

# My coder is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the expenses. But he's tryiong none the less. I've been using Movable-type on several websites for about a year and am worried about switching to anoth 2019/06/04 12:21 My coder is trying to persuade me to move to .net

My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the expenses.

But he's tryiong none the less. I've been using Movable-type on several websites for about a year and am
worried about switching to another platform.
I have heard fantastic things about blogengine.net. Is there a way I
can transfer all my wordpress content into it? Any help would be greatly
appreciated!

# This post presents clear idea in favor of the new visitors of blogging, that genuinely how to do blogging. 2019/06/04 23:08 This post presents clear idea in favor of the new

This post presents clear idea in favor of the new visitors
of blogging, that genuinely how to do blogging.

# Ahaa, its pleasant discussion on the topic of this article here at this weblog, I have read all that, so now me also commenting here. 2019/06/06 13:31 Ahaa, its pleasant discussion on the topic of this

Ahaa, its pleasant discussion on the topic of this
article here at this weblog, I have read all that, so now me also
commenting here.

# Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide other people. 2019/07/24 15:16 Hi, I do believe this is a great web site. I stumb

Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it.
Money and freedom is the best way to change, may you be rich and continue to guide other people.

# Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide other people. 2019/07/24 15:17 Hi, I do believe this is a great web site. I stumb

Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it.
Money and freedom is the best way to change, may you be rich and continue to guide other people.

# Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide other people. 2019/07/24 15:18 Hi, I do believe this is a great web site. I stumb

Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it.
Money and freedom is the best way to change, may you be rich and continue to guide other people.

# Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide other people. 2019/07/24 15:19 Hi, I do believe this is a great web site. I stumb

Hi, I do believe this is a great web site. I stumbledupon it ;) I'm going to revisit yet again since I saved as a favorite it.
Money and freedom is the best way to change, may you be rich and continue to guide other people.

# EODnUSVTCmMswmC 2021/07/03 1:35 https://www.hitabs.com/PAwOfotv

I think other web site proprietors should take this website as an model, very clean and magnificent user genial style and design, let alone the content. You are an expert in this topic!

# EylJOZfIKjAVZd 2021/07/03 4:34 https://www.blogger.com/profile/060647091882378654

Thanks for the blog post.Much thanks again. Awesome.

# Hmm is anyone else having problems with the images on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. 2021/08/30 20:31 Hmm is anyone else having problems with the images

Hmm is anyone else having problems with the images on this blog loading?

I'm trying to find out if its a problem on my end or if it's the blog.

Any responses would be greatly appreciated.

# Hmm is anyone else having problems with the images on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. 2021/08/30 20:32 Hmm is anyone else having problems with the images

Hmm is anyone else having problems with the images on this blog loading?

I'm trying to find out if its a problem on my end or if it's the blog.

Any responses would be greatly appreciated.

# Hmm is anyone else having problems with the images on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. 2021/08/30 20:33 Hmm is anyone else having problems with the images

Hmm is anyone else having problems with the images on this blog loading?

I'm trying to find out if its a problem on my end or if it's the blog.

Any responses would be greatly appreciated.

# Hmm is anyone else having problems with the images on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. 2021/08/30 20:34 Hmm is anyone else having problems with the images

Hmm is anyone else having problems with the images on this blog loading?

I'm trying to find out if its a problem on my end or if it's the blog.

Any responses would be greatly appreciated.

# I all the time used to read post in news papers but now as I am a user of internet so from now I am using net for posts, thanks to web. 2021/09/01 8:33 I all the time used to read post in news papers b

I all the time used to read post in news papers but now as I am a user
of internet so from now I am using net for posts, thanks to web.

# I all the time used to read post in news papers but now as I am a user of internet so from now I am using net for posts, thanks to web. 2021/09/01 8:34 I all the time used to read post in news papers b

I all the time used to read post in news papers but now as I am a user
of internet so from now I am using net for posts, thanks to web.

# I all the time used to read post in news papers but now as I am a user of internet so from now I am using net for posts, thanks to web. 2021/09/01 8:35 I all the time used to read post in news papers b

I all the time used to read post in news papers but now as I am a user
of internet so from now I am using net for posts, thanks to web.

# I all the time used to read post in news papers but now as I am a user of internet so from now I am using net for posts, thanks to web. 2021/09/01 8:36 I all the time used to read post in news papers b

I all the time used to read post in news papers but now as I am a user
of internet so from now I am using net for posts, thanks to web.

# I blog frequently and I genuinely appreciate your content. Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about once a week. I subscribed to your Feed as well. 2021/09/01 18:53 I blog frequently and I genuinely appreciate your

I blog frequently and I genuinely appreciate your content.
Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about
once a week. I subscribed to your Feed as well.

# I blog frequently and I genuinely appreciate your content. Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about once a week. I subscribed to your Feed as well. 2021/09/01 18:54 I blog frequently and I genuinely appreciate your

I blog frequently and I genuinely appreciate your content.
Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about
once a week. I subscribed to your Feed as well.

# I blog frequently and I genuinely appreciate your content. Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about once a week. I subscribed to your Feed as well. 2021/09/01 18:55 I blog frequently and I genuinely appreciate your

I blog frequently and I genuinely appreciate your content.
Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about
once a week. I subscribed to your Feed as well.

# I blog frequently and I genuinely appreciate your content. Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about once a week. I subscribed to your Feed as well. 2021/09/01 18:56 I blog frequently and I genuinely appreciate your

I blog frequently and I genuinely appreciate your content.
Your article has really peaked my interest. I am going to take a note of your website and keep checking for new details about
once a week. I subscribed to your Feed as well.

# Howdy! This is kind of off topic but I need some advice from an established blog. Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to beg 2021/09/02 2:41 Howdy! This is kind of off topic but I need some a

Howdy! This is kind of off topic but I need some advice from an established blog.
Is it very difficult to set up your own blog? I'm not very techincal
but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to begin. Do you have
any points or suggestions? With thanks

# Howdy! This is kind of off topic but I need some advice from an established blog. Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to beg 2021/09/02 2:42 Howdy! This is kind of off topic but I need some a

Howdy! This is kind of off topic but I need some advice from an established blog.
Is it very difficult to set up your own blog? I'm not very techincal
but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to begin. Do you have
any points or suggestions? With thanks

# Howdy! This is kind of off topic but I need some advice from an established blog. Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to beg 2021/09/02 2:43 Howdy! This is kind of off topic but I need some a

Howdy! This is kind of off topic but I need some advice from an established blog.
Is it very difficult to set up your own blog? I'm not very techincal
but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to begin. Do you have
any points or suggestions? With thanks

# Howdy! This is kind of off topic but I need some advice from an established blog. Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to beg 2021/09/02 2:44 Howdy! This is kind of off topic but I need some a

Howdy! This is kind of off topic but I need some advice from an established blog.
Is it very difficult to set up your own blog? I'm not very techincal
but I can figure things out pretty quick. I'm thinking about making my own but I'm not sure where to begin. Do you have
any points or suggestions? With thanks

# When someone writes an post he/she maintains the plan of a user in his/her brain that how a user can know it. Thus that's why this piece of writing is amazing. Thanks! 2021/09/06 7:26 When someone writes an post he/she maintains the p

When someone writes an post he/she maintains the
plan of a user in his/her brain that how a user
can know it. Thus that's why this piece of writing is amazing.

Thanks!

# When someone writes an post he/she maintains the plan of a user in his/her brain that how a user can know it. Thus that's why this piece of writing is amazing. Thanks! 2021/09/06 7:27 When someone writes an post he/she maintains the p

When someone writes an post he/she maintains the
plan of a user in his/her brain that how a user
can know it. Thus that's why this piece of writing is amazing.

Thanks!

# When someone writes an post he/she maintains the plan of a user in his/her brain that how a user can know it. Thus that's why this piece of writing is amazing. Thanks! 2021/09/06 7:28 When someone writes an post he/she maintains the p

When someone writes an post he/she maintains the
plan of a user in his/her brain that how a user
can know it. Thus that's why this piece of writing is amazing.

Thanks!

# When someone writes an post he/she maintains the plan of a user in his/her brain that how a user can know it. Thus that's why this piece of writing is amazing. Thanks! 2021/09/06 7:29 When someone writes an post he/she maintains the p

When someone writes an post he/she maintains the
plan of a user in his/her brain that how a user
can know it. Thus that's why this piece of writing is amazing.

Thanks!

# Amazing! Its truly awesome article, I have got much clear idea concerning from this piece of writing. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/12 14:08 Amazing! Its truly awesome article, I have got muc

Amazing! Its truly awesome article, I have got
much clear idea concerning from this piece of writing.

quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# We're a group of volunteers and opening a new scheme in our community. Your website provided us with valuable information to work on. You've done a formidable job and our whole community will be thankful to you. part time jobs hired in 30 minutes https:/ 2021/10/22 21:37 We're a group of volunteers and opening a new sche

We're a group of volunteers and opening a new scheme in our community.
Your website provided us with valuable information to work on.
You've done a formidable job and our whole community will be
thankful to you. part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/

# Fastidious response in return of this matter with solid arguments and describing everything on the topic of that. 2021/10/26 2:44 Fastidious response in return of this matter with

Fastidious response in return of this matter with solid arguments
and describing everything on the topic of that.

# Fastidious response in return of this matter with solid arguments and describing everything on the topic of that. 2021/10/26 2:45 Fastidious response in return of this matter with

Fastidious response in return of this matter with solid arguments
and describing everything on the topic of that.

# Fastidious response in return of this matter with solid arguments and describing everything on the topic of that. 2021/10/26 2:46 Fastidious response in return of this matter with

Fastidious response in return of this matter with solid arguments
and describing everything on the topic of that.

# It's a shame you don't have a donate button! I'd most certainly 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 brand new updates and will share this blog with 2021/11/12 17:56 It's a shame you don't have a donate button! I'd m

It's a shame you don't have a donate button! I'd most
certainly 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 brand new updates and will share this blog with my Facebook
group. Chat soon!

# It's a shame you don't have a donate button! I'd most certainly 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 brand new updates and will share this blog with 2021/11/12 17:56 It's a shame you don't have a donate button! I'd m

It's a shame you don't have a donate button! I'd most
certainly 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 brand new updates and will share this blog with my Facebook
group. Chat soon!

# It's a shame you don't have a donate button! I'd most certainly 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 brand new updates and will share this blog with 2021/11/12 17:57 It's a shame you don't have a donate button! I'd m

It's a shame you don't have a donate button! I'd most
certainly 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 brand new updates and will share this blog with my Facebook
group. Chat soon!

# It's a shame you don't have a donate button! I'd most certainly 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 brand new updates and will share this blog with 2021/11/12 17:58 It's a shame you don't have a donate button! I'd m

It's a shame you don't have a donate button! I'd most
certainly 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 brand new updates and will share this blog with my Facebook
group. Chat soon!

# Good article. I will be facing many of these issues as well.. 2021/11/14 21:41 Good article. I will be facing many of these issue

Good article. I will be facing many of these issues as well..

# ivermectin topical http://stromectolabc.com/
stromectol 3 mg tablets price 2022/02/07 17:20 Busjdhj

ivermectin topical http://stromectolabc.com/
stromectol 3 mg tablets price

# ivermectin buy online http://stromectolabc.com/
stromectol for sale 2022/02/08 3:24 Busjdhj

ivermectin buy online http://stromectolabc.com/
stromectol for sale

# ï»¿order stromectol online http://stromectolabc.com/
ivermectin canada 2022/02/08 10:11 Busjdhj

order stromectol online http://stromectolabc.com/
ivermectin canada

# rfdotplbrpzw 2022/06/03 4:00 yjkclngy

erythromycin medication http://erythromycinn.com/#

# ed medication https://erectionpills.best/
otc ed pills 2022/06/28 10:44 ErectionPills

ed medication https://erectionpills.best/
otc ed pills

タイトル
名前
URL
コメント