cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2186
Views
0
Helpful
6
Replies

CUPI.NET UserFull.GetUser - why no pAlias?

stephan.steiner
Spotlight
Spotlight

Hi

For some operations, I need to work with the UserFull object and I noted that UserFull.GetUser does not support extraction with an alias, only an objectId. So, I was extracting the UserBase first, then using its objectId to extract the UserFull which means more traffic. Looking at the source, UserFull.GetUser instantiates pUser by calling the constructor of UserFull, which has an optional parameter pAlias. If provided, you can get your UserFull based on the alias, rather than having to get the objectId first (and GetObjectIdFromAlias is private so that cannot be used).

Any chance to add the pAlias parameter to UserFull.GetUser so that it matches the GetUser of UserBase? If course I can use the UserFull contructor, but then I have no WebCallResult to work with thus breaking with the rest of the logic throughout my program.

Cheers

Stehpan

1 Accepted Solution

Accepted Solutions

The existing version of the SDK already supports this - just got around to trying it this morning.

the UserFull class constructor and static GetUser methods both have the same concept of passing an ObjectId in or optionally the alias instead (pass blank string for ObjectId in that case).  It does exactly that - looks the user up by alias with a fetch, grabs the ObjectId if a single match is found and does another fetch using the ObjectId to get the full set of properties which it populates into the UserFull class instance.

constructor:

UserFull oUserFull = new UserFull(connectionServer,"","operator");

static method:

UserFull oUserFull;

var res= UserFull.GetUser(out oUserFull, connectionServer, "", "operator");

View solution in original post

6 Replies 6

lindborg
Cisco Employee
Cisco Employee

I'll put this on the to-do list to look at - I have a vague memory of the alias search (as with getting a list of users) always returning the "short version" of users and to get the full one you had to do a full fetch using the objectId only - but I'll validate when I get a chance.

Hmm... isn't there a way to restrict the returned values to just the objectId.. so there'd be two calls, one just to get the objectId, and then an extract with the objectId.

The existing version of the SDK already supports this - just got around to trying it this morning.

the UserFull class constructor and static GetUser methods both have the same concept of passing an ObjectId in or optionally the alias instead (pass blank string for ObjectId in that case).  It does exactly that - looks the user up by alias with a fetch, grabs the ObjectId if a single match is found and does another fetch using the ObjectId to get the full set of properties which it populates into the UserFull class instance.

constructor:

UserFull oUserFull = new UserFull(connectionServer,"","operator");

static method:

UserFull oUserFull;

var res= UserFull.GetUser(out oUserFull, connectionServer, "", "operator");

That's for the constructor only though - I'm always using the Get methods as I can wrap them into a construct that tries one server after another if it doesn't work (based on the WebCallResult that is returned by the Get Operation). as the constructor returns UserFull, that approach won't work there and I'd have to write a separate wrapper method or simply updated the lib to add the new method (and I much prefer the second approach).

did you see my sample code?  The 2nd example is the static get method... am I missing something here?

No, you're not missing anything.. I did not bother to check all the constructor overrides.. number 3 does provide the parameters I'm looking for.

Sorry for the confusion. I must have temporarily misplaced my brain on moving day