static private TryParseUsername ( string username, string &sddl ) : bool | ||
username | string | The string to parse as a username. |
sddl | string | The SDDL format of a SID to return. |
리턴 | bool |
public void TryParseUsernameTest() { string param = null; // Test a string without backslashes. Assert.IsFalse(SidAttribute.TryParseUsername(@"foo", out param)); Assert.IsNull(param); // Test a string with backslashes but not a valid username. Assert.IsFalse(SidAttribute.TryParseUsername(@"foo\bar\baz", out param)); Assert.IsNull(param); // Test a valid username. Assert.IsTrue(SidAttribute.TryParseUsername(CurrentUsername, out param)); Assert.AreEqual <string>(CurrentSID, param); }
/// <summary> /// Transforms user account identifiers to security identifiers. /// </summary> /// <param name="engineIntrinsics">Provides access to the APIs for managing the transformation context.</param> /// <param name="inputData">The parameter argument that is to be transformed.</param> /// <returns>The transformed object.</returns> public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { // null may be allowed, so pass it through. if (inputData == null) { return(null); } // Convert account information to SDDL format. string username; if (LanguagePrimitives.TryConvertTo <string>(inputData, out username)) { string sddl; if (SidAttribute.TryParseUsername(username, out sddl)) { return(sddl); } } // Fallback to returning the original input data to further transformations. return(inputData); }