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

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

目次

Blog 利用状況

書庫

日記カテゴリ

ユーザの所属するグループの取得

DirectoryAccess クラスに追加したメソッドの1つ、ユーザの所属するグループを取得する GetBelongGroups メソッドの実装ですが、ユーザの所属するグループは ADSI の IADsUser.Groups メソッドで取得してます。

このメソッドの戻り値の型は IADsMembers で、IEnumerable を継承してるので For Each で回せます。

要素の型は基本インターフェイスである IADs を指定してます。

ドメインユーザの場合はこれでプライマリグループ(通常は Domain Users グループ)以外の所属するグループを取得できるんですが、プライマリグループが取得できないんです。

なので次のようにして、プライマリグループを取得してます。

 

1. グループの primaryGroupToken/グループ名 の組を GroupTokens プロパティ(キーは primaryGroupToken)に保持

2. ドメインユーザは primaryGroupID 属性を持っている(DomainUser.PrimaryGroupId プロパティに保持)

3. ドメインユーザの primaryGroupID = グループの primaryGroupToken なら、そのグループがユーザのプライマリグループなので、primaryGroupID をキーに GroupTokens プロパティからグループ名を取得

 

但し、グループの DirectoryEntry.Properties(PropertyCollection)内には primaryGroupToken プロパティがないので、LoadGroupTokens メソッド内で DirectoryEntry.Invoke メソッドを使ってプロパティを取得してます。

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

これは IADs.GetInfoEx(New Object() {"primaryGroupToken"}, 0) を呼び出したのと同じです。

つまり、次のように書くこともできます。

DirectCast(entry.NativeObject, IADs).GetInfoEx(New Object() {"primaryGroupToken"}, 0)

 

第1引数(vProperties パラメータ)は Object 型なんですが、取得したい属性の名前を Object 型の配列にして渡す必要があります。

第2引数(lnReserved パラメータ)は 0 を指定してますが理由は判らないのでお約束ということでお願いしますw

投稿日時 : 2013年7月11日 23:52

コメントを追加

# You really make it seem really easy together with your presentation but I to find this topic to be really something which I think I might by no means understand. It sort of feels too complicated and very large for me. I'm having a look ahead for your next 2019/05/30 3:14 You really make it seem really easy together with

You really make it seem really easy together with your presentation but I to find
this topic to be really something which I think I might by no means
understand. It sort of feels too complicated and very large for me.
I'm having a look ahead for your next put up, I will try to get the grasp of it!

# Your way of explaining everything in this piece of writing is truly pleasant, all can effortlessly understand it, Thanks a lot. 2019/06/04 11:27 Your way of explaining everything in this piece of

Your way of explaining everything in this piece of writing is truly pleasant, all can effortlessly understand it, Thanks a lot.

# Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult to write. 2019/07/18 10:38 Paragraph writing is also a excitement, if you be

Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult
to write.

# Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult to write. 2019/07/18 10:39 Paragraph writing is also a excitement, if you be

Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult
to write.

# Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult to write. 2019/07/18 10:40 Paragraph writing is also a excitement, if you be

Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult
to write.

# Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult to write. 2019/07/18 10:41 Paragraph writing is also a excitement, if you be

Paragraph writing is also a excitement, if you be acquainted with after that you can write if not it is difficult
to write.

# Illikebuisse lczca 2021/07/04 11:32 pharmaceptica.com

chloroquine tab https://pharmaceptica.com/

# erectile surgery 2021/07/12 12:37 hydroxychloroquine 200 mg side effects

is hydroxychloroquine safe to take https://plaquenilx.com/# hydroxychloroquine dangers

# re: ??????????????? 2021/08/06 23:11 hydroxichlorine

chloroquinine https://chloroquineorigin.com/# hydroxychloroquine use

# iuehxreusnrq 2021/11/30 8:11 dwedayyahh

buy hcq https://hydroxychloroquine20.com/

# Article writing is also a fun, if you know afterward you can write or else it is complicated to write. 2022/03/23 0:59 Article writing is also a fun, if you know afterwa

Article writing is also a fun, if you know afterward you can write or else it is complicated to write.

# Article writing is also a fun, if you know afterward you can write or else it is complicated to write. 2022/03/23 1:00 Article writing is also a fun, if you know afterwa

Article writing is also a fun, if you know afterward you can write or else it is complicated to write.

# Article writing is also a fun, if you know afterward you can write or else it is complicated to write. 2022/03/23 1:01 Article writing is also a fun, if you know afterwa

Article writing is also a fun, if you know afterward you can write or else it is complicated to write.

# Hmm is anyone else experiencing problems with the pictures on this blog loading? I'm trying to figure out if its a problem on my end or if it's the blog. Any feed-back would be greatly appreciated. 2022/03/25 6:50 Hmm is anyone else experiencing problems with the

Hmm is anyone else experiencing problems with the pictures on this blog loading?

I'm trying to figure out if its a problem on my end or if it's the blog.
Any feed-back would be greatly appreciated.

# eoeuuyukvnzc 2022/05/25 19:30 iqpbuzsy

how to apply erythromycin http://erythromycin1m.com/#

# Amazing! Its actually awesome paragraph, I have got much clear idea concerning from this paragraph. 2022/11/30 11:01 Amazing! Its actually awesome paragraph, I have go

Amazing! Its actually awesome paragraph, I have got much clear
idea concerning from this paragraph.

# Hello there! This is kind of off topic but I need some guidance 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 w 2022/12/04 1:41 Hello there! This is kind of off topic but I need

Hello there! This is kind of off topic but I need some guidance 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 start.
Do you have any ideas or suggestions? Thanks

# Test, just a test 2022/12/17 14:53 Proops

canadian customs pills vitamins http://candipharm.com/#

# cheap chloroquine 2022/12/26 12:50 MorrisReaks

hydroxychloroquine buy online https://hydroxychloroquinex.com/

タイトル  
名前  
URL
コメント