how to get number of user in a group from active directory - c#-4.0

I am trying to get number of user from a particular group?so how can i achieve?

Use the same approach, you did with groups ... Please find an example below.Add any properties like givenname, sn etc...
foreach(var group in froups){
DirectorySearcher ds = new DirectorySearcher(de, "(objectClass=person)");
ds.Filter = "(memberOf=CN=" + group + ",OU=Distribution Groups,DC=" + domain + ",DC=com)";
}

Related

Lotus Notes NAB - Adding a field

I have a project that I need to put an Internet Address and also add a new field called ShortName for all groups in the Notes NAB.
I am able to put the values and save the document , I tried with a doc.save and a computewithform. This is the Group form.
After the change, people in that group are no longer able to access the application.
Do you have an idea what I am doing wrong ?
User A is in group XYZ.
I added internetaddress xyz.com and a shortname text field xyzmigration
Application A is having an ACL with the group XYZ as editor. When User A tries to open the Application A, he get a not authorize. If I delete both values, User A is able to open the database.
Thanks for your help
$ServerAccess view validates Group documents and omits any Groups that has Shortname field present.
Normunds has the correct answer, but I want to add a suggestion: create a new group instead of modifying the existing group. I.e., if the group is "MyGroup", create a group named "MyGroup_Extended" and set it up with
Shortname = the value that you want
InternetAddress = the value that you want
Members = "MyGroup"
That way, you leave MyGroup untouched, but you still have a modified group document with the additional information added and the same member list.
And another thing: In order to make those groups that you already altered functional again, you should run a simple agent against all of the groups that does this:
FIELD ShortName := #DeleteField;
FIELD InternetAddress := #DeleteField;
After the help of some answers that I got here. I checked the view $ServerAccess. The selection formula is checking for a field Shortname and that is what was causing my problem. I will create another field name and we will be able to use this field instead of ShortName. allfields := #DocFields;
test1 := 0;
test2 := 0;
#For(i:=1; i < #Elements(allfields); i:=i+1; test1 := test1 + #If(#UpperCase(allfields[i]) = "LISTNAME";1;0));
#For(i:=1; i < #Elements(allfields); i:=i+1; test2:=test2 + #If(#UpperCase(allfields[i]) = "SHORTNAME";1;0));
SELECT (test1 < 2 & test2 = 0 &Type = "Group" & (#IsUnavailable ( GroupType)|GroupType="0" : "2":"3":"4")) & Form="Group" & #IsUnavailable($Conflict)
Thanks for your help.

The Requested Resources was not found or you do not have sufficient permissions to view it

Dynamics crm when retrieving value and updating it into another entity it showing like
The Requested Resources was not found or you do not have sufficient permissions to view it
i specified update ids like
enobj.Id=(Guid)context.OutputParameters["id"];
message:create
service :update on another entity
this is my code:
Query Expression query = new Query Expression();
query.EntityName = en.LogicalName;
query.ColumnSet = new ColumnSet("new_amount");
var x = service.RetrieveMultiple(query);
Entity enobj = new Entity("new_product");
int i = 0;
foreach (var item in x.Entities)
{
i = i + (int)item.Attributes["new_amount"];
enobj.Attributes["new_grandtotal"] = i;
}
enobj.Id=(Guid)context.OutputParameters["id"];
// en.Id = enobj.Id;
enobj.Id = en.Id;
service.Update(enobj);
message:create
service :update
i have two entites product and productlineitems
in productlineitems iam creating a record with the field amount 50 after creating that value.iam updating on product entity.
again i create productlineitem 2 with the value some 90.iam adding 50+90 =140
again lineitem 3 with the value. iam taking that on product entity
message:create --- productlineitems
service :update --- product
I think you are trying to update Product with Product Line Id. Try the following:
Replace
enobj.Id = en.Id;
With
// set the field name (key) based on what you got in system
enobj.Id = (Guid)en["new_productid"];
Also, Calling Context is set to Current user. So make sure that user have permissions to update Product.

Create user group as subgroup in WebSphere 7 (Portal)

In a portlet running on a websphere 7 portal server I want to create a new user group that is a subgroup of an existing group.
Here is the code (that I shortend as much as possible to keep the focus):
/* vars */
final PumaController controller = ...;
final PumaLocator locator = ...;
final PumaProfile pumeProfile = ...;
final groupCn = ... ;
/* code to add group */
final List<Group> parent = locator.findGroupsByAttribute("cn", CN_OF_GROUP);
final String parentDn = pumaProfile.getIdentifier(parent.get(0));
log.debug("creating new group with cn=" + groupCn + ", parentDn=" + parentDn);
newGroup = controller.createGroup(groupCn, parentDn, new HashMap<String, Object>(0));
The debug statement prints:
creating new group with
cn=[groupCn],
parentDn=cn=[CN_OF_GROUP],o=defaultWIMFileBasedRealm
The code DOES create a group. But it looks like the parentDN argument is ignored. The group is not created as a subgroup of parent, but it is created as a top level group. (Which is the same thing that happens if I pass null as parentDn).
What am I doing wrong here?
Probably nothing. I would raise a PMR if I were you.
If you configured federated security instead of standalone security please delete the file based realm by the way. You should always delete it when configuring federated security.

Getting RoleCollection as a string

We can get the roles of an SPUser by SPUser.Roles. But it will return SPRoleCollection. If we want to list all the roles we need to loop that.
For example an User has "Full Control","Read","Design" we need to loop the SPRoleCollection object.
How can i get all the roles as a string with ',' separator?
As a rough guess, try:
var user = SPUser // However you get the user.
var roles = Sring.Join(",", (from r in user.Roles select r.Name).ToArray()));
Though if you're using SharePoint 2010, the Name property is obsolete apparently.

Cognos 8 SDK: How to get Subgroups of a Group?

I try to get the Subgroup of a Group in the standard Cognos Namespace.
Quering the Contentstore to get ALL groups works fine.
The standard methodes to get "members" of objects return the users or only the "root" group (the group I want the subgroups of). Nothing else....
Am I doing something wrong or is it just "not to be done" ?
I found a way of doing it:
Assuming you have the searchpath for the group you want the subgroups of.
Query the contentstore for it with following PropEnum:
PropEnum[] props = {
PropEnum.defaultName,
PropEnum.searchPath,
PropEnum.members };
As result you get a BaseClass[] object (with only one element though...).
Import com.cognos.developer.schemas.bibus._3.Group <--- this is part of the Cognos SDK libraries and
now you can cast the object[0] to Group.
object.getMembers().getValue()[] is an array of all members INCLUDING groups, roles, accounts.
In java it looks like this (query for the object already done):
Group group = (Group)object[0];
BaseClass obj = null;
for (int i = 0; i < group.getMembers().getValue().length; i++){
obj = group.getMembers().getValue();
System.out.println(obj.getSearchPath().getValue());
}

Resources