获得user account的SID,GUID

1. 背景知识

When a new domain user or group account is created, Active Directory stores the account's SID in the Object-SID (objectSID) property of a User or Group object. It also assigns the new object a globally unique identifier (GUID), which is a 128-bit value that is unique not only in the enterprise but also across the world. GUIDs are assigned to every object created by Active Directory, not just User and Group objects. Each object's GUID is stored in its Object-GUID (objectGUID) property. When an object is assigned a GUID, it keeps that value for life. However, SIDs can sometimes change. The SID for a Group object won't change. 详见http://technet.microsoft.com/en-us/library/cc961625.aspx

2. 获得SID

a. command: wmic useraccount get name,sid 或 wmic useraccount list brief

b. 查看注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

3. 获得GUID

(using C#)

类名: System.DirectoryServices.DirectoryEntry

属性: NativeGuid

4. SID&GUID区别

1.AD里面创建一个用户或者组都会为其分配一个SID,同时也会为这些对象分配一个GUIDGUID是一个128位的字符串,一个标识符,GUID不仅在整个域里面是唯一的,并且在全世界的范围内都是唯一的,独一无二的,换句话说你找遍整个世界都找不到一模一样的两个GUID值。另外,不仅用户和组这些安全主体会被分配一个GUID,整个域内的所有对象都会被分配一个GUID,比如域控制器等。而且一旦对象被分配了GUID那么这个GUID将伴随这个对象一直到它被删掉。

2.SID可以被更改(一般组的SID不会更改),GUID不能被更改,对象的任何属性都可以改变,但唯独GUID不能被改变。

3.SID的作用主要是为对象和资源做权限控制用的

  GUID的作用主要是为了确定对象是谁对象在那里GUID一般都被复制到全局编录里面。比如我们平时在AD里面查找对象的时候,实际上查的是它的GUID

转载于:https://www.cnblogs.com/jenneyblog/archive/2013/01/04/useraccount_Sid_Guid.html

猜你喜欢

转载自blog.csdn.net/weixin_33951761/article/details/93370495