Skip to content

Add GraphRbac new library and clone the existing to Version1_6 folder #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix compilation error
  • Loading branch information
ankushbindlish2 committed Mar 27, 2019
commit 57da4b126d5dd5d9d8a1b90b5d844f8552246e9a
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public List<PSADObject> ListUserGroups(string principal)
public List<PSADObject> GetObjectsByObjectId(List<string> objectIds)
{
List<PSADObject> result = new List<PSADObject>();
IPage<AADObject> adObjects;
IPage<DirectoryObject> adObjects;
int objectIdBatchCount;
for(int i=0; i<objectIds.Count; i+=1000)
{
Expand Down Expand Up @@ -354,7 +354,7 @@ public void RemoveGroup(string groupObjectId)

public IEnumerable<PSADObject> GetGroupMembers(ADObjectFilterOptions options, ulong first = ulong.MaxValue, ulong skip = 0)
{
return new GenericPageEnumerable<AADObject>(
return new GenericPageEnumerable<DirectoryObject>(
delegate ()
{
return GraphClient.Groups.GetGroupMembers(options.Id);
Expand Down Expand Up @@ -450,7 +450,7 @@ public PSADApplication CreateApplication(CreatePSApplicationParameters createPar
{
if (ce.Response.StatusCode == HttpStatusCode.Forbidden)
{
AADObject currentUser = GraphClient.Objects.GetCurrentUser();
User currentUser = GraphClient.SignedInUser.Get();
if (currentUser != null && string.Equals(currentUser.UserType, "Guest", StringComparison.InvariantCultureIgnoreCase))
{
throw new InvalidOperationException(ProjectResources.CreateApplicationNotAllowedGuestUser);
Expand Down Expand Up @@ -815,7 +815,7 @@ public PSADServicePrincipal CreateServicePrincipal(CreatePSServicePrincipalParam
{
if (ce.Response.StatusCode == HttpStatusCode.Forbidden)
{
AADObject currentUser = GraphClient.Objects.GetCurrentUser();
User currentUser = GraphClient.SignedInUser.Get();
if (currentUser != null && string.Equals(currentUser.UserType, "Guest", StringComparison.InvariantCultureIgnoreCase))
{
throw new InvalidOperationException(ProjectResources.CreateServicePrincipalNotAllowedGuestUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,56 +48,49 @@ public static PSADObject AssignObjectId(PSADObject adObj, string objectId)
return adObj;
}

public static PSADObject ToPSADObject(this AADObject obj)
public static PSADObject ToPSADObject(this DirectoryObject obj)
{
if (obj == null) throw new ArgumentNullException();

if (obj.ObjectType == typeof(User).Name)
if (obj is User user)
{
var adUser = new PSADUser()
{
DisplayName = obj.DisplayName,
UserPrincipalName = obj.UserPrincipalName
DisplayName = user.DisplayName,
UserPrincipalName = user.UserPrincipalName
};

return AssignObjectId(adUser, obj.ObjectId);
}
else if (obj.ObjectType == "Group")
else if (obj is ADGroup group)
{
var adGroup = new PSADGroup()
{
DisplayName = obj.DisplayName,
SecurityEnabled = obj.SecurityEnabled,
MailNickname = obj.Mail
DisplayName = group.DisplayName,
SecurityEnabled = group.SecurityEnabled,
MailNickname = group.Mail
};
return AssignObjectId(adGroup, obj.ObjectId);
}
else if (obj.ObjectType == typeof(ServicePrincipal).Name)
else if (obj is ServicePrincipal servicePrincipal)
{
var adSp = new PSADServicePrincipal()
{
DisplayName = obj.DisplayName,
ServicePrincipalNames = obj.ServicePrincipalNames.ToArray()
DisplayName = servicePrincipal.DisplayName,
ServicePrincipalNames = servicePrincipal.ServicePrincipalNames.ToArray()
};

return AssignObjectId(adSp, obj.ObjectId);
}
else
{
var adObj = new PSADObject()
{
DisplayName = obj.DisplayName,
};

return AssignObjectId(adObj, obj.ObjectId);
}
throw new NotSupportedException($"{obj.GetType()}");
}

public static PSADObject ToPSADGroup(this AADObject obj)
public static PSADObject ToPSADGroup(this DirectoryObject obj)
{
var adObj = new PSADObject()
{
DisplayName = obj.DisplayName,
DisplayName = (obj as ADGroup).DisplayName,
};

return AssignObjectId(adObj, obj.ObjectId);
Expand Down