通过LDAP查找出来的结果的Properties中经常会包含byte[]类型的SId,并不是我们在AD中看到的s-x-x-形式的。通过以下函数将其转换。
1 /// <summary>
2 /// 转换Byte Sid to string
3 /// </summary>
4 /// <param name="sidBinary"></param>
5 /// <returns></returns>
6 public static string ConvertBinarySid2String(byte[] sidBinary)
7 {
8 SecurityIdentifier sid = new SecurityIdentifier(sidBinary, 0);
9 return sid.ToString();
10 }
2 /// 转换Byte Sid to string
3 /// </summary>
4 /// <param name="sidBinary"></param>
5 /// <returns></returns>
6 public static string ConvertBinarySid2String(byte[] sidBinary)
7 {
8 SecurityIdentifier sid = new SecurityIdentifier(sidBinary, 0);
9 return sid.ToString();
10 }