PageRenderTime 26ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ActiveDirectoryTests.cs

https://gitlab.com/jslee1/azure-powershell
C# | 711 lines | 578 code | 63 blank | 70 comment | 8 complexity | 704ac6bdb8038212e8f35164e8b25e41 MD5 | raw file
  1. // ----------------------------------------------------------------------------------
  2. //
  3. // Copyright Microsoft Corporation
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // ----------------------------------------------------------------------------------
  14. using Microsoft.Azure.Graph.RBAC;
  15. using Microsoft.Azure.Graph.RBAC.Models;
  16. using Microsoft.Azure.ServiceManagemenet.Common.Models;
  17. using Microsoft.Azure.Test;
  18. using Microsoft.WindowsAzure.Commands.ScenarioTest;
  19. using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
  20. using Xunit;
  21. using Xunit.Abstractions;
  22. namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests
  23. {
  24. public class ActiveDirectoryTests : RMTestBase
  25. {
  26. public ActiveDirectoryTests(ITestOutputHelper output)
  27. {
  28. XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
  29. }
  30. [Fact]
  31. [Trait(Category.AcceptanceType, Category.CheckIn)]
  32. public void TestGetAllADGroups()
  33. {
  34. const string scriptMethod = "Test-GetAllADGroups";
  35. Group newGroup = null;
  36. var controllerAdmin = ResourcesController.NewInstance;
  37. controllerAdmin.RunPsTestWorkflow(
  38. // scriptBuilder
  39. () =>
  40. {
  41. newGroup = CreateNewAdGroup(controllerAdmin);
  42. return new[] { scriptMethod };
  43. },
  44. // initialize
  45. null,
  46. // cleanup
  47. () =>
  48. {
  49. DeleteAdGroup(controllerAdmin, newGroup);
  50. },
  51. TestUtilities.GetCallingClass(),
  52. TestUtilities.GetCurrentMethodName());
  53. }
  54. [Fact]
  55. [Trait(Category.AcceptanceType, Category.CheckIn)]
  56. public void TestGetADGroupWithSearchString()
  57. {
  58. const string scriptMethod = "Test-GetADGroupWithSearchString '{0}'";
  59. Group newGroup = null;
  60. var controllerAdmin = ResourcesController.NewInstance;
  61. controllerAdmin.RunPsTestWorkflow(
  62. // scriptBuilder
  63. () =>
  64. {
  65. newGroup = CreateNewAdGroup(controllerAdmin);
  66. return new[] { string.Format(scriptMethod, newGroup.DisplayName) };
  67. },
  68. // initialize
  69. null,
  70. // cleanup
  71. () =>
  72. {
  73. DeleteAdGroup(controllerAdmin, newGroup);
  74. },
  75. TestUtilities.GetCallingClass(),
  76. TestUtilities.GetCurrentMethodName());
  77. }
  78. [Fact]
  79. [Trait(Category.AcceptanceType, Category.CheckIn)]
  80. public void TestGetADGroupWithBadSearchString()
  81. {
  82. ResourcesController.NewInstance.RunPsTest("Test-GetADGroupWithBadSearchString");
  83. }
  84. [Fact]
  85. [Trait(Category.AcceptanceType, Category.CheckIn)]
  86. public void TestGetADGroupWithObjectId()
  87. {
  88. const string scriptMethod = "Test-GetADGroupWithObjectId '{0}'";
  89. Group newGroup = null;
  90. var controllerAdmin = ResourcesController.NewInstance;
  91. controllerAdmin.RunPsTestWorkflow(
  92. // scriptBuilder
  93. () =>
  94. {
  95. newGroup = CreateNewAdGroup(controllerAdmin);
  96. return new[] { string.Format(scriptMethod, newGroup.ObjectId) };
  97. },
  98. // initialize
  99. null,
  100. // cleanup
  101. () =>
  102. {
  103. DeleteAdGroup(controllerAdmin, newGroup);
  104. },
  105. TestUtilities.GetCallingClass(),
  106. TestUtilities.GetCurrentMethodName());
  107. }
  108. [Fact]
  109. [Trait(Category.AcceptanceType, Category.CheckIn)]
  110. public void TestGetADGroupSecurityEnabled()
  111. {
  112. const string scriptMethod = "Test-GetADGroupSecurityEnabled '{0}' '{1}'";
  113. Group newGroup = null;
  114. var controllerAdmin = ResourcesController.NewInstance;
  115. controllerAdmin.RunPsTestWorkflow(
  116. // scriptBuilder
  117. () =>
  118. {
  119. newGroup = CreateNewAdGroup(controllerAdmin);
  120. return new[] { string.Format(scriptMethod, newGroup.ObjectId, newGroup.SecurityEnabled) };
  121. },
  122. // initialize
  123. null,
  124. // cleanup
  125. () =>
  126. {
  127. DeleteAdGroup(controllerAdmin, newGroup);
  128. },
  129. TestUtilities.GetCallingClass(),
  130. TestUtilities.GetCurrentMethodName());
  131. }
  132. [Fact]
  133. [Trait(Category.AcceptanceType, Category.CheckIn)]
  134. public void TestGetADGroupWithBadObjectId()
  135. {
  136. ResourcesController.NewInstance.RunPsTest("Test-GetADGroupWithBadObjectId");
  137. }
  138. [Fact]
  139. [Trait(Category.AcceptanceType, Category.CheckIn)]
  140. public void TestGetADGroupWithUserObjectId()
  141. {
  142. const string scriptMethod = "Test-GetADGroupWithUserObjectId '{0}'";
  143. User newUser = null;
  144. var controllerAdmin = ResourcesController.NewInstance;
  145. controllerAdmin.RunPsTestWorkflow(
  146. // scriptBuilder
  147. () =>
  148. {
  149. newUser = CreateNewAdUser(controllerAdmin);
  150. return new[] { string.Format(scriptMethod, newUser.ObjectId) };
  151. },
  152. // initialize
  153. null,
  154. // cleanup
  155. () =>
  156. {
  157. DeleteAdUser(controllerAdmin, newUser);
  158. },
  159. TestUtilities.GetCallingClass(),
  160. TestUtilities.GetCurrentMethodName());
  161. }
  162. [Fact]
  163. [Trait(Category.AcceptanceType, Category.CheckIn)]
  164. public void TestGetADGroupMemberWithGroupObjectId()
  165. {
  166. const string scriptMethod = "Test-GetADGroupMemberWithGroupObjectId '{0}' '{1}' '{2}'";
  167. User newUser = null;
  168. Group newGroup = null;
  169. var controllerAdmin = ResourcesController.NewInstance;
  170. controllerAdmin.RunPsTestWorkflow(
  171. // scriptBuilder
  172. () =>
  173. {
  174. newUser = CreateNewAdUser(controllerAdmin);
  175. newGroup = CreateNewAdGroup(controllerAdmin);
  176. string memberUrl = string.Format(
  177. "{0}{1}/directoryObjects/{2}",
  178. controllerAdmin.GraphClient.BaseUri.AbsoluteUri,
  179. controllerAdmin.GraphClient.TenantID,
  180. newUser.ObjectId);
  181. controllerAdmin.GraphClient.Group.AddMember(newGroup.ObjectId, new GroupAddMemberParameters(memberUrl));
  182. return new[] { string.Format(scriptMethod, newGroup.ObjectId, newUser.ObjectId, newUser.DisplayName) };
  183. },
  184. // initialize
  185. null,
  186. // cleanup
  187. () =>
  188. {
  189. DeleteAdUser(controllerAdmin, newUser);
  190. DeleteAdGroup(controllerAdmin, newGroup);
  191. },
  192. TestUtilities.GetCallingClass(),
  193. TestUtilities.GetCurrentMethodName());
  194. }
  195. [Fact]
  196. [Trait(Category.AcceptanceType, Category.CheckIn)]
  197. public void TestGetADGroupMemberWithBadGroupObjectId()
  198. {
  199. ResourcesController.NewInstance.RunPsTest("Test-GetADGroupMemberWithBadGroupObjectId");
  200. }
  201. [Fact]
  202. [Trait(Category.AcceptanceType, Category.CheckIn)]
  203. public void TestGetADGroupMemberWithUserObjectId()
  204. {
  205. const string scriptMethod = "Test-GetADGroupMemberWithUserObjectId '{0}'";
  206. User newUser = null;
  207. var controllerAdmin = ResourcesController.NewInstance;
  208. controllerAdmin.RunPsTestWorkflow(
  209. // scriptBuilder
  210. () =>
  211. {
  212. newUser = CreateNewAdUser(controllerAdmin);
  213. return new[] { string.Format(scriptMethod, newUser.ObjectId) };
  214. },
  215. // initialize
  216. null,
  217. // cleanup
  218. () =>
  219. {
  220. DeleteAdUser(controllerAdmin, newUser);
  221. },
  222. TestUtilities.GetCallingClass(),
  223. TestUtilities.GetCurrentMethodName());
  224. }
  225. [Fact]
  226. [Trait(Category.AcceptanceType, Category.CheckIn)]
  227. public void TestGetADGroupMemberFromEmptyGroup()
  228. {
  229. const string scriptMethod = "Test-GetADGroupMemberFromEmptyGroup '{0}'";
  230. Group newGroup = null;
  231. var controllerAdmin = ResourcesController.NewInstance;
  232. controllerAdmin.RunPsTestWorkflow(
  233. // scriptBuilder
  234. () =>
  235. {
  236. newGroup = CreateNewAdGroup(controllerAdmin);
  237. return new[] { string.Format(scriptMethod, newGroup.ObjectId) };
  238. },
  239. // initialize
  240. null,
  241. // cleanup
  242. () =>
  243. {
  244. DeleteAdGroup(controllerAdmin, newGroup);
  245. },
  246. TestUtilities.GetCallingClass(),
  247. TestUtilities.GetCurrentMethodName());
  248. }
  249. [Fact]
  250. [Trait(Category.AcceptanceType, Category.CheckIn)]
  251. public void TestGetADServicePrincipalWithObjectId()
  252. {
  253. const string scriptMethod = "Test-GetADServicePrincipalWithObjectId '{0}'";
  254. ServicePrincipal newServicePrincipal = null;
  255. Application app = null;
  256. var controllerAdmin = ResourcesController.NewInstance;
  257. controllerAdmin.RunPsTestWorkflow(
  258. // scriptBuilder
  259. () =>
  260. {
  261. app = CreateNewAdApp(controllerAdmin);
  262. newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId);
  263. return new[] { string.Format(scriptMethod, newServicePrincipal.ObjectId) };
  264. },
  265. // initialize
  266. null,
  267. // cleanup
  268. () =>
  269. {
  270. DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal);
  271. DeleteAdApp(controllerAdmin, app);
  272. },
  273. TestUtilities.GetCallingClass(),
  274. TestUtilities.GetCurrentMethodName());
  275. }
  276. [Fact]
  277. [Trait(Category.AcceptanceType, Category.CheckIn)]
  278. public void TestGetADServicePrincipalWithBadObjectId()
  279. {
  280. ResourcesController.NewInstance.RunPsTest("Test-GetADServicePrincipalWithBadObjectId");
  281. }
  282. [Fact]
  283. [Trait(Category.AcceptanceType, Category.CheckIn)]
  284. public void TestGetADServicePrincipalWithUserObjectId()
  285. {
  286. const string scriptMethod = "Test-GetADServicePrincipalWithUserObjectId '{0}'";
  287. User newUser = null;
  288. var controllerAdmin = ResourcesController.NewInstance;
  289. controllerAdmin.RunPsTestWorkflow(
  290. // scriptBuilder
  291. () =>
  292. {
  293. newUser = CreateNewAdUser(controllerAdmin);
  294. return new[] { string.Format(scriptMethod, newUser.ObjectId) };
  295. },
  296. // initialize
  297. null,
  298. // cleanup
  299. () =>
  300. {
  301. DeleteAdUser(controllerAdmin, newUser);
  302. },
  303. TestUtilities.GetCallingClass(),
  304. TestUtilities.GetCurrentMethodName());
  305. }
  306. [Fact]
  307. [Trait(Category.AcceptanceType, Category.CheckIn)]
  308. public void TestGetADServicePrincipalWithSPN()
  309. {
  310. const string scriptMethod = "Test-GetADServicePrincipalWithSPN '{0}'";
  311. ServicePrincipal newServicePrincipal = null;
  312. Application app = null;
  313. var controllerAdmin = ResourcesController.NewInstance;
  314. controllerAdmin.RunPsTestWorkflow(
  315. // scriptBuilder
  316. () =>
  317. {
  318. app = CreateNewAdApp(controllerAdmin);
  319. newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId);
  320. return new[] { string.Format(scriptMethod, newServicePrincipal.ServicePrincipalNames[1]) };
  321. },
  322. // initialize
  323. null,
  324. // cleanup
  325. () =>
  326. {
  327. DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal);
  328. DeleteAdApp(controllerAdmin, app);
  329. },
  330. TestUtilities.GetCallingClass(),
  331. TestUtilities.GetCurrentMethodName());
  332. }
  333. [Fact]
  334. [Trait(Category.AcceptanceType, Category.CheckIn)]
  335. public void TestGetADServicePrincipalWithBadSPN()
  336. {
  337. ResourcesController.NewInstance.RunPsTest("Test-GetADServicePrincipalWithBadSPN");
  338. }
  339. [Fact]
  340. [Trait(Category.AcceptanceType, Category.CheckIn)]
  341. public void TestGetADServicePrincipalWithSearchString()
  342. {
  343. const string scriptMethod = "Test-GetADServicePrincipalWithSearchString '{0}'";
  344. ServicePrincipal newServicePrincipal = null;
  345. Application app = null;
  346. var controllerAdmin = ResourcesController.NewInstance;
  347. controllerAdmin.RunPsTestWorkflow(
  348. // scriptBuilder
  349. () =>
  350. {
  351. app = CreateNewAdApp(controllerAdmin);
  352. newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId);
  353. return new[] { string.Format(scriptMethod, newServicePrincipal.DisplayName) };
  354. },
  355. // initialize
  356. null,
  357. // cleanup
  358. () =>
  359. {
  360. DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal);
  361. DeleteAdApp(controllerAdmin, app);
  362. },
  363. TestUtilities.GetCallingClass(),
  364. TestUtilities.GetCurrentMethodName());
  365. }
  366. [Fact]
  367. [Trait(Category.AcceptanceType, Category.CheckIn)]
  368. public void TestGetADServicePrincipalWithBadSearchString()
  369. {
  370. ResourcesController.NewInstance.RunPsTest("Test-GetADServicePrincipalWithBadSearchString");
  371. }
  372. [Fact]
  373. [Trait(Category.AcceptanceType, Category.CheckIn)]
  374. public void TestGetAllADUser()
  375. {
  376. const string scriptMethod = "Test-GetAllADUser";
  377. User newUser = null;
  378. var controllerAdmin = ResourcesController.NewInstance;
  379. controllerAdmin.RunPsTestWorkflow(
  380. // scriptBuilder
  381. () =>
  382. {
  383. newUser = CreateNewAdUser(controllerAdmin);
  384. return new[] { string.Format(scriptMethod) };
  385. },
  386. // initialize
  387. null,
  388. // cleanup
  389. () =>
  390. {
  391. DeleteAdUser(controllerAdmin, newUser);
  392. },
  393. TestUtilities.GetCallingClass(),
  394. TestUtilities.GetCurrentMethodName());
  395. }
  396. [Fact]
  397. [Trait(Category.AcceptanceType, Category.CheckIn)]
  398. public void TestGetADUserWithObjectId()
  399. {
  400. const string scriptMethod = "Test-GetADUserWithObjectId '{0}'";
  401. User newUser = null;
  402. var controllerAdmin = ResourcesController.NewInstance;
  403. controllerAdmin.RunPsTestWorkflow(
  404. // scriptBuilder
  405. () =>
  406. {
  407. newUser = CreateNewAdUser(controllerAdmin);
  408. return new[] { string.Format(scriptMethod, newUser.ObjectId) };
  409. },
  410. // initialize
  411. null,
  412. // cleanup
  413. () =>
  414. {
  415. DeleteAdUser(controllerAdmin, newUser);
  416. },
  417. TestUtilities.GetCallingClass(),
  418. TestUtilities.GetCurrentMethodName());
  419. }
  420. [Fact]
  421. [Trait(Category.AcceptanceType, Category.CheckIn)]
  422. public void TestGetADUserWithMail()
  423. {
  424. const string scriptMethod = "Test-GetADUserWithMail '{0}'";
  425. User newUser = null;
  426. var controllerAdmin = ResourcesController.NewInstance;
  427. controllerAdmin.RunPsTestWorkflow(
  428. // scriptBuilder
  429. () =>
  430. {
  431. newUser = CreateNewAdUser(controllerAdmin);
  432. return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) };
  433. },
  434. // initialize
  435. null,
  436. // cleanup
  437. () =>
  438. {
  439. DeleteAdUser(controllerAdmin, newUser);
  440. },
  441. TestUtilities.GetCallingClass(),
  442. TestUtilities.GetCurrentMethodName());
  443. }
  444. [Fact]
  445. [Trait(Category.AcceptanceType, Category.CheckIn)]
  446. public void TestGetADUserWithBadObjectId()
  447. {
  448. ResourcesController.NewInstance.RunPsTest("Test-GetADUserWithBadObjectId");
  449. }
  450. [Fact]
  451. [Trait(Category.AcceptanceType, Category.CheckIn)]
  452. public void TestGetADUserWithGroupObjectId()
  453. {
  454. const string scriptMethod = "Test-GetADUserWithGroupObjectId '{0}'";
  455. Group newGroup = null;
  456. var controllerAdmin = ResourcesController.NewInstance;
  457. controllerAdmin.RunPsTestWorkflow(
  458. // scriptBuilder
  459. () =>
  460. {
  461. newGroup = CreateNewAdGroup(controllerAdmin);
  462. return new[] { string.Format(scriptMethod, newGroup.ObjectId) };
  463. },
  464. // initialize
  465. null,
  466. // cleanup
  467. () =>
  468. {
  469. DeleteAdGroup(controllerAdmin, newGroup);
  470. },
  471. TestUtilities.GetCallingClass(),
  472. TestUtilities.GetCurrentMethodName());
  473. }
  474. [Fact]
  475. [Trait(Category.AcceptanceType, Category.CheckIn)]
  476. public void TestGetADUserWithUPN()
  477. {
  478. const string scriptMethod = "Test-GetADUserWithUPN '{0}'";
  479. User newUser = null;
  480. var controllerAdmin = ResourcesController.NewInstance;
  481. controllerAdmin.RunPsTestWorkflow(
  482. // scriptBuilder
  483. () =>
  484. {
  485. newUser = CreateNewAdUser(controllerAdmin);
  486. return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) };
  487. },
  488. // initialize
  489. null,
  490. // cleanup
  491. () =>
  492. {
  493. DeleteAdUser(controllerAdmin, newUser);
  494. },
  495. TestUtilities.GetCallingClass(),
  496. TestUtilities.GetCurrentMethodName());
  497. }
  498. [Fact(Skip = "Currently not working.")]
  499. public void TestGetADUserWithFPOUPN()
  500. {
  501. ResourcesController.NewInstance.RunPsTest("Test-GetADUserWithFPOUPN");
  502. }
  503. [Fact]
  504. [Trait(Category.AcceptanceType, Category.CheckIn)]
  505. public void TestGetADUserWithBadUPN()
  506. {
  507. ResourcesController.NewInstance.RunPsTest("Test-GetADUserWithBadUPN");
  508. }
  509. [Fact]
  510. [Trait(Category.AcceptanceType, Category.CheckIn)]
  511. public void TestGetADUserWithSearchString()
  512. {
  513. const string scriptMethod = "Test-GetADUserWithSearchString '{0}'";
  514. User newUser = null;
  515. var controllerAdmin = ResourcesController.NewInstance;
  516. controllerAdmin.RunPsTestWorkflow(
  517. // scriptBuilder
  518. () =>
  519. {
  520. newUser = CreateNewAdUser(controllerAdmin);
  521. return new[] { string.Format(scriptMethod, newUser.DisplayName) };
  522. },
  523. // initialize
  524. null,
  525. // cleanup
  526. () =>
  527. {
  528. DeleteAdUser(controllerAdmin, newUser);
  529. },
  530. TestUtilities.GetCallingClass(),
  531. TestUtilities.GetCurrentMethodName());
  532. }
  533. [Fact]
  534. [Trait(Category.AcceptanceType, Category.CheckIn)]
  535. public void TestGetADUserWithBadSearchString()
  536. {
  537. ResourcesController.NewInstance.RunPsTest("Test-GetADUserWithBadSearchString");
  538. }
  539. [Fact]
  540. [Trait(Category.AcceptanceType, Category.CheckIn)]
  541. public void TestNewADApplication()
  542. {
  543. ResourcesController.NewInstance.RunPsTest("Test-NewADApplication");
  544. }
  545. [Fact]
  546. [Trait(Category.AcceptanceType, Category.CheckIn)]
  547. public void TestNewADServicePrincipal()
  548. {
  549. const string scriptMethod = "Test-NewADServicePrincipal '{0}'";
  550. Application application = null;
  551. var controllerAdmin = ResourcesController.NewInstance;
  552. controllerAdmin.RunPsTestWorkflow(
  553. // scriptBuilder
  554. () =>
  555. {
  556. application = CreateNewAdApp(controllerAdmin);
  557. return new[] { string.Format(scriptMethod, application.AppId) };
  558. },
  559. // initialize
  560. null,
  561. // cleanup
  562. () =>
  563. {
  564. DeleteAdApp(controllerAdmin, application);
  565. },
  566. TestUtilities.GetCallingClass(),
  567. TestUtilities.GetCurrentMethodName());
  568. }
  569. private User CreateNewAdUser(ResourcesController controllerAdmin)
  570. {
  571. var name = TestUtilities.GenerateName("aduser");
  572. var parameter = new UserCreateParameters
  573. {
  574. DisplayName = name,
  575. UserPrincipalName = name + "@" + controllerAdmin.UserDomain,
  576. AccountEnabled = true,
  577. MailNickname = name + "test",
  578. PasswordProfileSettings = new UserCreateParameters.PasswordProfile
  579. {
  580. ForceChangePasswordNextLogin = false,
  581. Password = TestUtilities.GenerateName("adpass") + "0#$"
  582. }
  583. };
  584. return controllerAdmin.GraphClient.User.Create(parameter).User;
  585. }
  586. private Group CreateNewAdGroup(ResourcesController controllerAdmin)
  587. {
  588. var parameter = new GroupCreateParameters
  589. {
  590. DisplayName = TestUtilities.GenerateName("adgroup"),
  591. MailNickname = TestUtilities.GenerateName("adgroupmail"),
  592. SecurityEnabled = true
  593. };
  594. return controllerAdmin.GraphClient.Group.Create(parameter).Group;
  595. }
  596. private Application CreateNewAdApp(ResourcesController controllerAdmin)
  597. {
  598. var appName = TestUtilities.GenerateName("adApplication");
  599. var url = string.Format("http://{0}/home", appName);
  600. var appParam = new ApplicationCreateParameters
  601. {
  602. AvailableToOtherTenants = false,
  603. DisplayName = appName,
  604. Homepage = url,
  605. IdentifierUris = new[] { url },
  606. ReplyUrls = new[] { url }
  607. };
  608. return controllerAdmin.GraphClient.Application.Create(appParam).Application;
  609. }
  610. private ServicePrincipal CreateNewAdServicePrincipal(ResourcesController controllerAdmin, string appId)
  611. {
  612. var spParam = new ServicePrincipalCreateParameters
  613. {
  614. AppId = appId,
  615. AccountEnabled = true
  616. };
  617. return controllerAdmin.GraphClient.ServicePrincipal.Create(spParam).ServicePrincipal;
  618. }
  619. private void DeleteAdUser(ResourcesController controllerAdmin, User user)
  620. {
  621. if (user != null)
  622. {
  623. controllerAdmin.GraphClient.User.Delete(user.ObjectId);
  624. }
  625. }
  626. private void DeleteAdGroup(ResourcesController controllerAdmin, Group group)
  627. {
  628. if (group != null)
  629. {
  630. controllerAdmin.GraphClient.Group.Delete(group.ObjectId);
  631. }
  632. }
  633. private void DeleteAdApp(ResourcesController controllerAdmin, Application app)
  634. {
  635. if (app != null)
  636. {
  637. controllerAdmin.GraphClient.Application.Delete(app.ObjectId);
  638. }
  639. }
  640. private void DeleteAdServicePrincipal(ResourcesController controllerAdmin, ServicePrincipal newServicePrincipal)
  641. {
  642. if (newServicePrincipal != null)
  643. {
  644. controllerAdmin.GraphClient.ServicePrincipal.Delete(newServicePrincipal.ObjectId);
  645. }
  646. }
  647. }
  648. }